HONEYCOMB: Remove
[csit.git] / tests / nsh_sfc / sfc_scripts / install_sfc.sh
1 #!/bin/bash
2
3 set -x
4
5 ROOTDIR=/tmp/openvpp-testing
6 PWDDIR=$(pwd)
7
8 if_name1=$1
9 if_name2=$2
10
11 VPP_VERSION=`cat ${ROOTDIR}/NSH_SFC_VER | grep VPP | awk -F'= ' '{print $2}'`
12 NSH_SFC_VERSION=`cat ${ROOTDIR}/NSH_SFC_VER | grep NSH_SFC | awk -F'= ' '{print $2}'`
13
14 VPP_CODE_DIR=${ROOTDIR}/vpp_codes
15 NSH_SFC_CODE_DIR=${ROOTDIR}/nsh_sfc_codes
16
17 #at first, we need to stop the vpp service if have
18 sudo service vpp stop
19
20 #uninstall the vpp and nsh sfc plugin
21 #and git clone the vpp and nsh sfc plugin source codes
22 #then compile and install them in the dut nodes.
23 nsh_need_install=0
24 sudo dpkg -l vpp-nsh-plugin >/dev/null 2>&1
25 if [ $? -eq 0 ]; then
26     nsh_plugin_version=`dpkg -s vpp-nsh-plugin | grep Version | awk -F' ' '{print $2}'`
27     if [ "${nsh_plugin_version}" \< "${NSH_SFC_VERSION}" ]; then
28         sudo dpkg -P vpp-nsh-plugin vpp-nsh-plugin-dbg vpp-nsh-plugin-dev >/dev/null 2>&1
29         test $? -eq 0 || exit 1
30         nsh_need_install=1
31     fi
32 else
33     nsh_need_install=1
34 fi
35
36 vpp_need_install=0
37 sudo dpkg -l vpp >/dev/null 2>&1
38 if [ $? -eq 0 ]; then
39     vpp_version=`dpkg -s vpp | grep Version | awk -F' ' '{print $2}'`
40     if [ "${vpp_version}" \< "${VPP_VERSION}" ]; then
41         sudo dpkg -P vpp vpp-dbg vpp-dev vpp-dpdk-dev vpp-dpdk-dkms vpp-lib \
42                      vpp-plugins vpp-python-api >/dev/null 2>&1
43         test $? -eq 0 || exit 1
44         vpp_need_install=1
45     fi
46 else
47     vpp_need_install=1
48 fi
49
50 sleep 5
51
52 ##begin to clone the vpp source code
53 if [ ${vpp_need_install} -eq 1 ]; then
54     sudo rm -rf ${VPP_CODE_DIR}
55     sudo mkdir -p ${VPP_CODE_DIR}
56     cd ${VPP_CODE_DIR}
57     git clone -b v${VPP_VERSION} https://gerrit.fd.io/r/vpp
58
59     #compile the vpp code
60     cd ./vpp/build-root/
61     make distclean
62     ./bootstrap.sh
63     make V=0 PLATFORM=vpp TAG=vpp install-deb
64
65     #after that, install vpp
66     sudo dpkg -i *.deb
67     cd ${PWDDIR}
68 fi
69
70 ##begin to clone the nsh sfc source code
71 if [ ${nsh_need_install} -eq 1 ]; then
72     sudo rm -rf ${NSH_SFC_CODE_DIR}
73     sudo mkdir -p ${NSH_SFC_CODE_DIR}
74     cd ${NSH_SFC_CODE_DIR}
75     git clone -b v${NSH_SFC_VERSION} https://gerrit.fd.io/r/nsh_sfc
76
77     #compile the nsh sfc code
78     cd ./nsh_sfc/nsh-plugin/
79     sudo rm -rf build
80     sudo ./build.sh
81
82     #after that, install the nsh sfc plugin
83     cd ./packaging/
84     sudo dpkg -i *.deb
85     cd ${PWDDIR}
86 fi
87
88 #check and setup the hugepages
89 SYS_HUGEPAGE=$(cat /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages)
90 if [ ${SYS_HUGEPAGE} -lt 1024 ]; then
91     MOUNT=$(mount | grep /mnt/huge)
92     while [ "${MOUNT}" != "" ]
93     do
94         sudo umount /mnt/huge
95         sleep 1
96         MOUNT=$(mount | grep /mnt/huge)
97     done
98
99     echo 2048 | sudo tee /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages
100     echo 2048 | sudo tee /sys/devices/system/node/node1/hugepages/hugepages-2048kB/nr_hugepages
101
102     sudo mkdir -p /mnt/huge
103     sudo mount -t hugetlbfs nodev /mnt/huge/
104     test $? -eq 0 || exit 1
105 fi
106
107 #check and set the max map count
108 SYS_MAP=$(cat /proc/sys/vm/max_map_count)
109 if [ ${SYS_MAP} -lt 200000 ]; then
110     echo 200000 | sudo tee /proc/sys/vm/max_map_count
111 fi
112
113 #after all, we can start the vpp service now
114 sudo service vpp start