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="http://dpdk.org/browse/dpdk/snapshot/dpdk-16.04.zip"
28 DPDK_DIR=$VNF_CORE/dpdk
31 # Sets QUIT variable so script will finish.
48 read -p "Enter Proxy : " proxy
49 export http_proxy=$proxy
50 export https_proxy=$proxy
51 echo "Acquire::http::proxy \"$http_proxy\";" | sudo tee -a /etc/apt/apt.conf > /dev/null
52 echo "Acquire::https::proxy \"$http_proxy\";" | sudo tee -a /etc/apt/apt.conf > /dev/null
54 wget -T 20 -t 3 --spider http://www.google.com > /dev/null 2>&1
55 if [ "$?" != 0 ]; then
56 echo -e "No Internet connection. Proxy incorrect? Try again"
57 echo -e "eg: http://<proxy>:<port>"
62 echo "Network connectivity successful."
67 TITLE="Environment setup."
69 TEXT[1]="Check OS and network connection"
74 # a. Check for OS dependencies
75 source /etc/os-release
76 if [[ $VERSION_ID != "16.04" ]] ; then
77 echo "WARNING: It is recommended to use Ubuntu 16.04..Your version is "$VERSION_ID
79 echo "Ubuntu 16.04 OS requirement met..."
82 echo "Checking network connectivity..."
83 # b. Check for internet connections
84 wget -T 20 -t 3 --spider http://www.google.com > /dev/null 2>&1
85 if [ "$?" != 0 ]; then
87 read -p "No Internet connection. Are you behind a proxy (y/n)? " yn
89 [Yy]* ) $SETUP_PROXY ; return;;
90 [Nn]* ) echo "Please check your internet connection..." ; exit;;
91 * ) "Please answer yes or no.";;
95 echo "Network connectivity successful."
100 TITLE="Download and Install"
102 TEXT[1]="Agree to download"
103 FUNC[1]="get_agreement_download"
104 TEXT[2]="Download packages"
105 FUNC[2]="install_libs"
106 TEXT[3]="Download DPDK zip"
107 FUNC[3]="download_dpdk_zip"
108 TEXT[4]="Build and Install DPDK"
109 FUNC[4]="install_dpdk"
110 TEXT[5]="Setup hugepages"
111 FUNC[5]="setup_hugepages"
113 get_agreement_download()
116 echo "List of packages needed for VNFs build and installation:"
117 echo "-------------------------------------------------------"
118 echo "1. DPDK version 16.04"
119 echo "2. build-essential"
120 echo "3. linux-headers-generic"
123 echo "6. libpcap-dev"
125 echo "8. and other library dependencies"
127 read -p "We need download above mentioned package. Press (y/n) to continue? " yn
133 * ) "Please answer yes or no.";;
140 echo "Install libs needed to build and run VNFs..."
142 if [ ! -e "$file_name" ]; then
143 echo "Please choose option '2.Agree to download' first"
146 file_name=".download"
147 if [ -e "$file_name" ]; then
152 sudo apt-get -y install build-essential linux-headers-$(uname -r) git unzip libpcap0.8-dev gcc \
153 make libc6 libc6-dev g++-multilib libzmq3-dev libcurl4-openssl-dev
159 echo "Download DPDK zip"
161 if [ ! -e "$file_name" ]; then
162 echo "Please choose option '2.Agree to download' first"
166 if [ ! -e ${DPDK_DOWNLOAD##*/} ] ; then
167 wget ${DPDK_DOWNLOAD}
169 unzip -o ${DPDK_DOWNLOAD##*/}
170 mv $VNF_CORE/dpdk-16.04 $VNF_CORE/dpdk
177 if [ ! -d "$DPDK_DIR" ]; then
178 echo "Please choose option '4 Download DPDK zip'"
182 export RTE_TARGET=x86_64-native-linuxapp-gcc
185 echo "Apply dpdk custom patches..."
186 patch -p0 < $VNF_CORE/patches/dpdk_custom_patch/rte_pipeline.patch
187 patch -p1 < $VNF_CORE/patches/dpdk_custom_patch/i40e-fix-link-management.patch
188 patch -p1 < $VNF_CORE/patches/dpdk_custom_patch/i40e-fix-Rx-hang-when-disable-LLDP.patch
189 patch -p1 < $VNF_CORE/patches/dpdk_custom_patch/i40e-fix-link-status-change-interrupt.patch
190 patch -p1 < $VNF_CORE/patches/dpdk_custom_patch/i40e-fix-VF-bonded-device-link-down.patch
192 make -j install T=$RTE_TARGET
193 if [ $? -ne 0 ] ; then
194 echo "Failed to build dpdk, please check the errors."
198 if [ $? -ne 0 ] ; then
199 sudo $MODPROBE -v uio
200 sudo $INSMOD $RTE_TARGET/kmod/igb_uio.ko
201 sudo cp -f $RTE_TARGET/kmod/igb_uio.ko /lib/modules/$(uname -r)
202 echo "uio" | sudo tee -a /etc/modules
203 echo "igb_uio" | sudo tee -a /etc/modules
213 if [[ "$HUGEPGSZ" = "2048kB" ]] ; then
216 if [ ! "`grep nr_hugepages /etc/sysctl.conf`" ] ; then
217 echo "vm.nr_hugepages=$Pages" | sudo tee /etc/sysctl.conf
221 sudo service procps start
223 grep -s '/dev/hugepages' /proc/mounts
224 if [ $? -ne 0 ] ; then
225 echo "Creating /mnt/huge and mounting as hugetlbfs"
226 sudo mkdir -p /mnt/huge
227 sudo mount -t hugetlbfs nodev /mnt/huge
228 echo "nodev /mnt/huge hugetlbfs defaults 0 0" | sudo tee -a /etc/fstab > /dev/null
236 TEXT[1]="Build all VNFs (vACL, vCGNAPT, vFW)"
243 if [ ! -d "$DPDK_DIR" ]; then
244 echo "Please choose option '4 Download DPDK zip'"
248 if [ ! -d "$DPDK_DIR/x86_64-native-linuxapp-gcc" ]; then
249 echo "Please choose option '5 Build and Install DPDK'"
253 export RTE_SDK=$DPDK_DIR
254 export RTE_TARGET=x86_64-native-linuxapp-gcc
257 make || { echo -e "\nVNF: Make failed\n"; }
261 SETUP_PROXY="setup_http_proxy"
270 echo -n "Checking for user permission.. "
272 if [ $? -ne 0 ]; then
273 echo "Password-less sudo user must run this script" 1>&2
279 while [ "$QUIT" == "0" ]; do
281 for s in $(seq ${#STEPS[@]}) ; do
284 echo "----------------------------------------------------------"
285 echo " Step $s: ${TITLE}"
286 echo "----------------------------------------------------------"
288 for i in $(seq ${#TEXT[@]}) ; do
289 echo "[$OPTION_NUM] ${TEXT[i]}"
290 OPTIONS[$OPTION_NUM]=${FUNC[i]}
294 # Clear TEXT and FUNC arrays before next step
301 echo "[$OPTION_NUM] Exit Script"
302 OPTIONS[$OPTION_NUM]="quit"
307 ${OPTIONS[our_entry]} ${our_entry}
309 if [ "$QUIT" == "0" ] ; then
311 echo -n "Press enter to continue ..."; read
316 echo "Installation successfully complete."