3 # Copyright (c) 2017 Intel Corporation
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 cd $(dirname ${BASH_SOURCE[0]})/..
20 echo "------------------------------------------------------------------------------"
21 echo " VNF_CORE exported as $VNF_CORE"
22 echo "------------------------------------------------------------------------------"
24 HUGEPGSZ=`cat /proc/meminfo | grep Hugepagesize | cut -d : -f 2 | tr -d ' '`
25 MODPROBE="/sbin/modprobe"
27 DPDK_DOWNLOAD="Not initialized"
28 DPDK_DIR=$VNF_CORE/dpdk
32 # Sets QUIT variable so script will finish.
49 read -p "Enter Proxy : " proxy
50 export http_proxy=$proxy
51 export https_proxy=$proxy
52 echo "Acquire::http::proxy \"$http_proxy\";" | sudo tee -a /etc/apt/apt.conf > /dev/null
53 echo "Acquire::https::proxy \"$http_proxy\";" | sudo tee -a /etc/apt/apt.conf > /dev/null
55 wget -T 20 -t 3 --spider http://www.google.com > /dev/null 2>&1
56 if [ "$?" != 0 ]; then
57 echo -e "No Internet connection. Proxy incorrect? Try again"
58 echo -e "eg: http://<proxy>:<port>"
63 echo "Network connectivity successful."
68 TITLE="Environment setup."
70 TEXT[1]="Check OS and network connection"
72 TEXT[2]="Select DPDK RTE version"
73 FUNC[2]="select_dpdk_rte_ver"
77 # a. Check for OS dependencies
78 source /etc/os-release
79 if [[ $VERSION_ID != "16.04" ]] ; then
80 echo "WARNING: It is recommended to use Ubuntu 16.04..Your version is "$VERSION_ID
82 echo "Ubuntu 16.04 OS requirement met..."
85 echo "Checking network connectivity..."
86 # b. Check for internet connections
87 wget -T 20 -t 3 --spider http://www.google.com > /dev/null 2>&1
88 if [ "$?" != 0 ]; then
90 read -p "No Internet connection. Are you behind a proxy (y/n)? " yn
92 [Yy]* ) $SETUP_PROXY ; return;;
93 [Nn]* ) echo "Please check your internet connection..." ; exit;;
94 * ) "Please answer yes or no.";;
98 echo "Network connectivity successful."
100 select_dpdk_rte_ver()
103 TITLE="Select the DPDK RTE version"
105 echo "[1] DPDK 16.04"
106 echo "[2] DPDK 16.11"
107 echo "[3] DPDK 17.02"
108 echo "[4] DPDK 17.05"
112 read -p "Select DPDK version to be used: " yn
114 [1]* ) DPDK_RTE_VER=16.04 ; return;;
115 [2]* ) DPDK_RTE_VER=16.11 ; return;;
116 [3]* ) DPDK_RTE_VER=17.02 ; return;;
117 [4]* ) DPDK_RTE_VER=17.05 ; return;;
118 * ) echo " Invalid selection...";;
125 TITLE="Download and Install"
127 TEXT[1]="Agree to download"
128 FUNC[1]="get_agreement_download"
129 TEXT[2]="Download packages"
130 FUNC[2]="install_libs"
131 TEXT[3]="Download DPDK zip"
132 FUNC[3]="download_dpdk_zip"
133 TEXT[4]="Build and Install DPDK"
134 FUNC[4]="install_dpdk"
135 TEXT[5]="Setup hugepages"
136 FUNC[5]="setup_hugepages"
138 get_agreement_download()
141 echo "List of packages needed for VNFs build and installation:"
142 echo "-------------------------------------------------------"
143 echo "1. DPDK version $DPDK_RTE_VER"
144 echo "2. build-essential"
145 echo "3. linux-headers-generic"
148 echo "6. libpcap-dev"
150 echo "8. and other library dependencies"
152 read -p "We need download above mentioned package. Press (y/n) to continue? " yn
158 * ) "Please answer yes or no.";;
165 echo "Install libs needed to build and run VNFs..."
167 if [ ! -e "$file_name" ]; then
168 echo "Please choose option '2.Agree to download' first"
171 file_name=".download"
172 if [ -e "$file_name" ]; then
177 sudo apt-get -y install build-essential linux-headers-$(uname -r) git unzip libpcap0.8-dev gcc \
178 make libc6 libc6-dev g++-multilib libzmq3-dev libcurl4-openssl-dev
184 echo "Download DPDK zip"
186 if [ ! -e "$file_name" ]; then
187 echo "Please choose option '2.Agree to download' first"
190 DPDK_DOWNLOAD="http://dpdk.org/browse/dpdk/snapshot/dpdk-$DPDK_RTE_VER.zip"
192 if [ ! -e ${DPDK_DOWNLOAD##*/} ] ; then
193 wget ${DPDK_DOWNLOAD}
195 unzip -o ${DPDK_DOWNLOAD##*/}
196 mv $VNF_CORE/dpdk-$DPDK_RTE_VER $VNF_CORE/dpdk
203 if [ ! -d "$DPDK_DIR" ]; then
204 echo "Please choose option '4 Download DPDK zip'"
208 export RTE_TARGET=x86_64-native-linuxapp-gcc
212 if [ $DPDK_RTE_VER == "16.04" ] ; then
213 echo "Apply dpdk custom patches..."
214 patch -p1 < $VNF_CORE/patches/dpdk_custom_patch/i40e-fix-link-management.patch
215 patch -p1 < $VNF_CORE/patches/dpdk_custom_patch/i40e-fix-Rx-hang-when-disable-LLDP.patch
216 patch -p1 < $VNF_CORE/patches/dpdk_custom_patch/i40e-fix-link-status-change-interrupt.patch
217 patch -p1 < $VNF_CORE/patches/dpdk_custom_patch/i40e-fix-VF-bonded-device-link-down.patch
218 patch -p1 < $VNF_CORE/patches/dpdk_custom_patch/disable-acl-debug-logs.patch
219 patch -p1 < $VNF_CORE/patches/dpdk_custom_patch/set-log-level-to-info.patch
222 make -j install T=$RTE_TARGET
223 if [ $? -ne 0 ] ; then
224 echo "Failed to build dpdk, please check the errors."
228 if [ $? -ne 0 ] ; then
229 sudo $MODPROBE -v uio
230 sudo $INSMOD $RTE_TARGET/kmod/igb_uio.ko
231 sudo cp -f $RTE_TARGET/kmod/igb_uio.ko /lib/modules/$(uname -r)
232 echo "uio" | sudo tee -a /etc/modules
233 echo "igb_uio" | sudo tee -a /etc/modules
243 if [[ "$HUGEPGSZ" = "2048kB" ]] ; then
246 if [ ! "`grep nr_hugepages /etc/sysctl.conf`" ] ; then
247 echo "vm.nr_hugepages=$Pages" | sudo tee /etc/sysctl.conf
251 sudo service procps start
253 grep -s '/dev/hugepages' /proc/mounts
254 if [ $? -ne 0 ] ; then
255 echo "Creating /mnt/huge and mounting as hugetlbfs"
256 sudo mkdir -p /mnt/huge
257 sudo mount -t hugetlbfs nodev /mnt/huge
258 echo "nodev /mnt/huge hugetlbfs defaults 0 0" | sudo tee -a /etc/fstab > /dev/null
266 TEXT[1]="Build all VNFs (vACL, vCGNAPT, vFW, UDP_Replay)"
273 if [ ! -d "$DPDK_DIR" ]; then
274 echo "Please choose option '4 Download DPDK zip'"
278 if [ ! -d "$DPDK_DIR/x86_64-native-linuxapp-gcc" ]; then
279 echo "Please choose option '5 Build and Install DPDK'"
283 export RTE_SDK=$DPDK_DIR
284 export RTE_TARGET=x86_64-native-linuxapp-gcc
287 make || { echo -e "\nVNF: Make failed\n"; }
291 #--- Add non intractive option to build vnfs
292 if [[ "$1" = "--silient" ]];then
293 DPDK_VER=("" "16.04" "16.11" "17.02" "17.05")
295 for item in "${DPDK_VER[@]}"; do
296 if [[ "$member" == "$item" ]]; then
297 DPDK_RTE_VER="$member"
302 echo "Install required libraries..."
306 echo "Download dpdk for VNF build..."
312 echo "Setup hugepages..."
322 SETUP_PROXY="setup_http_proxy"
331 echo -n "Checking for user permission.. "
333 if [ $? -ne 0 ]; then
334 echo "Password-less sudo user must run this script" 1>&2
340 while [ "$QUIT" == "0" ]; do
342 for s in $(seq ${#STEPS[@]}) ; do
345 echo "----------------------------------------------------------"
346 echo " Step $s: ${TITLE}"
347 echo "----------------------------------------------------------"
349 for i in $(seq ${#TEXT[@]}) ; do
350 echo "[$OPTION_NUM] ${TEXT[i]}"
351 OPTIONS[$OPTION_NUM]=${FUNC[i]}
355 # Clear TEXT and FUNC arrays before next step
362 echo "[$OPTION_NUM] Exit Script"
363 OPTIONS[$OPTION_NUM]="quit"
368 ${OPTIONS[our_entry]} ${our_entry}
370 if [ "$QUIT" == "0" ] ; then
372 echo -n "Press enter to continue ..."; read
377 echo "Installation successfully complete."