forked from omec-project/il_trafficgen
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·322 lines (288 loc) · 7.96 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
#! /bin/bash
# Copyright (c) 2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cd $(dirname ${BASH_SOURCE[0]})
source ./services.cfg
export IL_TGEN=$PWD
echo "------------------------------------------------------------------------------"
echo " il_trafficgen exported as $IL_TGEN"
echo "------------------------------------------------------------------------------"
HUGEPGSZ=`cat /proc/meminfo | grep Hugepagesize | cut -d : -f 2 | tr -d ' '`
IL_TGEN_MEMORY=6144*2 #il_trafficgen=6144MB + responder=6144MB Huge Page Memory
MODPROBE="/sbin/modprobe"
INSMOD="/sbin/insmod"
DPDK_DIR=$IL_TGEN/dpdk
IL_TGEN_DIR=$IL_TGEN/pktgen
#
# Sets QUIT variable so script will finish.
#
quit()
{
QUIT=$1
}
# Shortcut for quit.
q()
{
quit
}
setup_http_proxy()
{
while true; do
echo
read -p "Enter Proxy : " proxy
export http_proxy=$proxy
export https_proxy=$proxy
echo "Acquire::http::proxy \"$http_proxy\";" | sudo tee -a /etc/apt/apt.conf > /dev/null
echo "Acquire::https::proxy \"$http_proxy\";" | sudo tee -a /etc/apt/apt.conf > /dev/null
wget -T 20 -t 3 --spider http://www.google.com
if [ "$?" != 0 ]; then
echo -e "No Internet connection. Proxy incorrect? Try again"
echo -e "eg: http://<proxy>:<port>"
exit 1
fi
return
done
}
step_1()
{
TITLE="Environment setup."
CONFIG_NUM=1
TEXT[1]="Check OS and network connection"
FUNC[1]="setup_env"
}
setup_env()
{
# a. Check for OS dependencies
source /etc/os-release
if [[ $VERSION_ID != "16.04" ]] ; then
echo "WARNING: It is recommended to use Ubuntu 16.04..Your version is "$VERSION_ID
echo "The libboost 1.58 dependency is not met by official Ubuntu PPA. Either attempt"
echo "to find/compile boost 1.58 or upgrade your distribution by performing 'sudo do-release-upgrade'"
else
echo "Ubuntu 16.04 OS requirement met..."
fi
echo
echo "Checking network connectivity..."
# b. Check for internet connections
wget -T 20 -t 3 --spider http://www.google.com
if [ "$?" != 0 ]; then
while true; do
read -p "No Internet connection. Are you behind a proxy (y/n)? " yn
case $yn in
[Yy]* ) $SETUP_PROXY ; return;;
[Nn]* ) echo "Please check your internet connection..." ; exit;;
* ) "Please answer yes or no.";;
esac
done
fi
}
step_2()
{
TITLE="Download and Install"
CONFIG_NUM=1
TEXT[1]="Agree to download"
FUNC[1]="get_agreement_download"
TEXT[2]="Upgrade Ubuntu 16.04 LTS [OPTIONAL]"
FUNC[2]="upgrade_os"
TEXT[3]="Download packages"
FUNC[3]="install_libs"
TEXT[4]="Setup Huge Pages"
FUNC[4]="setup_hugepages"
TEXT[5]="Download DPDK submodule"
FUNC[5]="updt_dpdk_submodule"
TEXT[6]="Install DPDK"
FUNC[6]="install_dpdk"
}
get_agreement_download()
{
echo
echo "List of packages needed for IL_TRAFFICGEN build and installation:"
echo "-------------------------------------------------------"
echo "1. DPDK"
echo "2. build-essential"
echo "3. linux-headers-generic"
echo "4. git"
echo "5. unzip"
echo "6. libpcap-dev"
echo "7. make"
echo "8. curl"
echo "9. openssl-dev"
echo "10. and other library dependencies"
while true; do
read -p "We need download above mentioned package. Press (y/n) to continue? " yn
case $yn in
[Yy]* )
touch .agree
return;;
[Nn]* ) exit;;
* ) "Please answer yes or no.";;
esac
done
}
upgrade_os()
{
echo "Upgrade Ubuntu 16.04 LTS to build and run IL_TRAFFICGEN..."
file_name=".agree"
if [ ! -e "$file_name" ]; then
echo "Please choose option '2. Agree to download' first"
return
fi
file_name=".download"
if [ -e "$file_name" ]; then
clear
return
fi
sudo apt-get upgrade
sudo apt-get install linux-headers-$(uname -r)
touch .download
}
install_libs()
{
echo "Install libs needed to build and run IL_TRAFFICGEN..."
file_name=".agree"
if [ ! -e "$file_name" ]; then
echo "Please choose option '2. Agree to download' first"
return
fi
file_name=".download"
if [ -e "$file_name" ]; then
clear
#return
fi
sudo apt-get update
sudo apt-get -y install curl build-essential linux-headers-$(uname -r) \
git unzip libpcap0.8-dev gcc libjson0-dev make libc6 libc6-dev \
g++-multilib libcurl4-openssl-dev libssl-dev msr-tools libnuma-dev \
libconfig-dev
touch .download
}
setup_hugepages()
{
echo -e "Setting up $(($IL_TGEN_MEMORY)) huge page memory..."
echo -e "Hugepagesize=\t$HUGEPGSZ"
Hugepgsz=`echo $HUGEPGSZ | tr -d 'kB'`
Pages=$((($IL_TGEN_MEMORY*1024) / $Hugepgsz))
echo -e "Number of huge pages=\t$Pages"
if [ ! "`grep nr_hugepages /etc/sysctl.conf`" ]; then
echo "vm.nr_hugepages=$Pages" | sudo tee /etc/sysctl.conf
else
echo "vm.nr_hugepages=$Pages"
sudo sed -i '/^vm.nr_hugepages=/s/=.*/='$Pages'/' /etc/sysctl.conf
fi
sudo sysctl -p
sudo service procps start
grep -s '/dev/hugepages' /proc/mounts
if [ $? -ne 0 ] ; then
echo "Creating /mnt/huge and mounting as hugetlbfs"
sudo mkdir -p /mnt/huge
sudo mount -t hugetlbfs nodev /mnt/huge
echo "nodev /mnt/huge hugetlbfs defaults 0 0" | sudo tee -a /etc/fstab > /dev/null
fi
}
updt_dpdk_submodule()
{
echo "Download DPDK submodule"
file_name=".agree"
if [ ! -e "$file_name" ]; then
echo "Please choose option '2. Agree to download' first"
return
fi
git submodule init
git submodule update
}
install_dpdk()
{
echo "Build DPDK"
export RTE_TARGET=x86_64-native-linuxapp-gcc
cp -f dpdk-16.04_common_linuxapp "$DPDK_DIR"/config/common_linuxapp
pushd "$DPDK_DIR"
make -j 20 install T="$RTE_TARGET"
if [ $? -ne 0 ] ; then
echo "Failed to build dpdk, please check the errors."
return
fi
sudo modinfo igb_uio
if [ $? -ne 0 ] ; then
sudo $MODPROBE -v uio
sudo $INSMOD "$RTE_TARGET"/kmod/igb_uio.ko
sudo cp -f "$RTE_TARGET"/kmod/igb_uio.ko /lib/modules/"$(uname -r)"
echo "uio" | sudo tee -a /etc/modules
echo "igb_uio" | sudo tee -a /etc/modules
sudo depmod
fi
popd
}
step_3()
{
TITLE="Build IL_TRAFFICGEN"
CONFIG_NUM=1
TEXT[1]="Build IL_TRAFFICGEN"
FUNC[1]="build_il_tgen"
}
build_il_tgen()
{
source setenv.sh
pushd $IL_TGEN_DIR
echo "IL_TGEN_DIR= $IL_TGEN_DIR"
echo -e "RTE_SDK=$RTE_SDK\nRTE_TARGET=$RTE_TARGET"
make clean; make
popd
}
SETUP_PROXY="setup_http_proxy"
STEPS[1]="step_1"
STEPS[2]="step_2"
STEPS[3]="step_3"
QUIT=0
clear
echo -n "Checking for user permission.. "
sudo -n true
if [ $? -ne 0 ]; then
echo "Password-less sudo user must run this script" 1>&2
exit 1
fi
echo "Done"
clear
while [ "$QUIT" == "0" ]; do
OPTION_NUM=1
for s in $(seq ${#STEPS[@]}) ; do
${STEPS[s]}
echo "----------------------------------------------------------"
echo " Step $s: ${TITLE}"
echo "----------------------------------------------------------"
for i in $(seq ${#TEXT[@]}) ; do
echo "[$OPTION_NUM] ${TEXT[i]}"
OPTIONS[$OPTION_NUM]=${FUNC[i]}
let "OPTION_NUM+=1"
done
# Clear TEXT and FUNC arrays before next step
unset TEXT
unset FUNC
echo ""
done
echo "[$OPTION_NUM] Exit Script"
OPTIONS[$OPTION_NUM]="quit"
echo ""
echo -n "Option: "
read our_entry
echo ""
${OPTIONS[our_entry]} ${our_entry}
if [ "$QUIT" == "0" ] ; then
echo
echo -n "Press enter to continue ..."; read
clear
continue
exit
fi
echo "Installation complete. Please refer to README.MD for more information"
done