mininet / util / install.sh @ 312ed1a4
History | View | Annotate | Download (24.3 KB)
1 |
#!/usr/bin/env bash |
---|---|
2 |
|
3 |
# Mininet install script for Ubuntu (and Debian Wheezy+) |
4 |
# Brandon Heller (brandonh@stanford.edu) |
5 |
|
6 |
# Fail on error |
7 |
set -e |
8 |
|
9 |
# Fail on unset var usage |
10 |
set -o nounset |
11 |
|
12 |
# Get directory containing mininet folder |
13 |
MININET_DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd -P )" |
14 |
|
15 |
# Set up build directory, which by default is the working directory |
16 |
# unless the working directory is a subdirectory of mininet, |
17 |
# in which case we use the directory containing mininet |
18 |
BUILD_DIR="$(pwd -P)" |
19 |
case $BUILD_DIR in |
20 |
$MININET_DIR/*) BUILD_DIR=$MININET_DIR;; # currect directory is a subdirectory |
21 |
*) BUILD_DIR=$BUILD_DIR;; |
22 |
esac |
23 |
|
24 |
# Location of CONFIG_NET_NS-enabled kernel(s) |
25 |
KERNEL_LOC=http://www.openflow.org/downloads/mininet |
26 |
|
27 |
# Attempt to identify Linux release |
28 |
|
29 |
DIST=Unknown |
30 |
RELEASE=Unknown |
31 |
CODENAME=Unknown |
32 |
ARCH=`uname -m` |
33 |
if [ "$ARCH" = "x86_64" ]; then ARCH="amd64"; fi |
34 |
if [ "$ARCH" = "i686" ]; then ARCH="i386"; fi |
35 |
|
36 |
test -e /etc/debian_version && DIST="Debian" |
37 |
grep Ubuntu /etc/lsb-release &> /dev/null && DIST="Ubuntu" |
38 |
if [ "$DIST" = "Ubuntu" ] || [ "$DIST" = "Debian" ]; then |
39 |
install='sudo apt-get -y install' |
40 |
remove='sudo apt-get -y remove' |
41 |
pkginst='sudo dpkg -i' |
42 |
# Prereqs for this script |
43 |
if ! which lsb_release &> /dev/null; then |
44 |
$install lsb-release |
45 |
fi |
46 |
fi |
47 |
test -e /etc/fedora-release && DIST="Fedora" |
48 |
test -e /etc/redhat-release && DIST="RedHatEnterpriseServer" |
49 |
if [ "$DIST" = "Fedora" -o "$DIST" = "RedHatEnterpriseServer" ]; then |
50 |
install='sudo yum -y install' |
51 |
remove='sudo yum -y erase' |
52 |
pkginst='sudo rpm -ivh' |
53 |
# Prereqs for this script |
54 |
if ! which lsb_release &> /dev/null; then |
55 |
$install redhat-lsb-core |
56 |
fi |
57 |
fi |
58 |
if which lsb_release &> /dev/null; then |
59 |
DIST=`lsb_release -is` |
60 |
RELEASE=`lsb_release -rs` |
61 |
CODENAME=`lsb_release -cs` |
62 |
fi |
63 |
echo "Detected Linux distribution: $DIST $RELEASE $CODENAME $ARCH" |
64 |
|
65 |
# Kernel params |
66 |
|
67 |
KERNEL_NAME=`uname -r` |
68 |
KERNEL_HEADERS=kernel-headers-${KERNEL_NAME} |
69 |
|
70 |
if ! echo $DIST | egrep 'Ubuntu|Debian|Fedora|RedHatEnterpriseServer'; then |
71 |
echo "Install.sh currently only supports Ubuntu, Debian, RedHat and Fedora." |
72 |
exit 1 |
73 |
fi |
74 |
|
75 |
# More distribution info |
76 |
DIST_LC=`echo $DIST | tr [A-Z] [a-z]` # as lower case |
77 |
|
78 |
|
79 |
# Determine whether version $1 >= version $2 |
80 |
# usage: if version_ge 1.20 1.2.3; then echo "true!"; fi |
81 |
function version_ge { |
82 |
# sort -V sorts by *version number* |
83 |
latest=`printf "$1\n$2" | sort -V | tail -1` |
84 |
# If $1 is latest version, then $1 >= $2 |
85 |
[ "$1" == "$latest" ] |
86 |
} |
87 |
|
88 |
|
89 |
# Kernel Deb pkg to be removed: |
90 |
KERNEL_IMAGE_OLD=linux-image-2.6.26-33-generic |
91 |
|
92 |
DRIVERS_DIR=/lib/modules/${KERNEL_NAME}/kernel/drivers/net |
93 |
|
94 |
OVS_RELEASE=1.4.0 |
95 |
OVS_PACKAGE_LOC=https://github.com/downloads/mininet/mininet |
96 |
OVS_BUILDSUFFIX=-ignore # was -2 |
97 |
OVS_PACKAGE_NAME=ovs-$OVS_RELEASE-core-$DIST_LC-$RELEASE-$ARCH$OVS_BUILDSUFFIX.tar |
98 |
OVS_TAG=v$OVS_RELEASE |
99 |
|
100 |
OF13_SWITCH_REV=${OF13_SWITCH_REV:-""} |
101 |
|
102 |
|
103 |
function kernel { |
104 |
echo "Install Mininet-compatible kernel if necessary" |
105 |
sudo apt-get update |
106 |
if ! $install linux-image-$KERNEL_NAME; then |
107 |
echo "Could not install linux-image-$KERNEL_NAME" |
108 |
echo "Skipping - assuming installed kernel is OK." |
109 |
fi |
110 |
} |
111 |
|
112 |
function kernel_clean { |
113 |
echo "Cleaning kernel..." |
114 |
|
115 |
# To save disk space, remove previous kernel |
116 |
if ! $remove $KERNEL_IMAGE_OLD; then |
117 |
echo $KERNEL_IMAGE_OLD not installed. |
118 |
fi |
119 |
|
120 |
# Also remove downloaded packages: |
121 |
rm -f $HOME/linux-headers-* $HOME/linux-image-* |
122 |
} |
123 |
|
124 |
# Install Mininet deps |
125 |
function mn_deps { |
126 |
echo "Installing Mininet dependencies" |
127 |
if [ "$DIST" = "Fedora" -o "$DIST" = "RedHatEnterpriseServer" ]; then |
128 |
$install gcc make socat psmisc xterm openssh-clients iperf \ |
129 |
iproute telnet python-setuptools libcgroup-tools \ |
130 |
ethtool help2man pyflakes pylint python-pep8 |
131 |
else |
132 |
$install gcc make socat psmisc xterm ssh iperf iproute telnet \ |
133 |
python-setuptools cgroup-bin ethtool help2man \ |
134 |
pyflakes pylint pep8 |
135 |
fi |
136 |
|
137 |
echo "Installing Mininet core" |
138 |
pushd $MININET_DIR/mininet |
139 |
sudo make install |
140 |
popd |
141 |
} |
142 |
|
143 |
# Install Mininet developer dependencies |
144 |
function mn_dev { |
145 |
echo "Installing Mininet developer dependencies" |
146 |
$install doxygen doxypy texlive-fonts-recommended |
147 |
if ! $install doxygen-latex; then |
148 |
echo "doxygen-latex not needed" |
149 |
fi |
150 |
} |
151 |
|
152 |
# The following will cause a full OF install, covering: |
153 |
# -user switch |
154 |
# The instructions below are an abbreviated version from |
155 |
# http://www.openflowswitch.org/wk/index.php/Debian_Install |
156 |
function of { |
157 |
echo "Installing OpenFlow reference implementation..." |
158 |
cd $BUILD_DIR |
159 |
$install autoconf automake libtool make gcc |
160 |
if [ "$DIST" = "Fedora" -o "$DIST" = "RedHatEnterpriseServer" ]; then |
161 |
$install git pkgconfig glibc-devel |
162 |
else |
163 |
$install git-core autotools-dev pkg-config libc6-dev |
164 |
fi |
165 |
# was: git clone git://openflowswitch.org/openflow.git |
166 |
# Use our own fork on github for now: |
167 |
git clone git://github.com/mininet/openflow |
168 |
cd $BUILD_DIR/openflow |
169 |
|
170 |
# Patch controller to handle more than 16 switches |
171 |
patch -p1 < $MININET_DIR/mininet/util/openflow-patches/controller.patch |
172 |
|
173 |
# Resume the install: |
174 |
./boot.sh |
175 |
./configure |
176 |
make |
177 |
sudo make install |
178 |
cd $BUILD_DIR |
179 |
} |
180 |
|
181 |
function of13 { |
182 |
echo "Installing OpenFlow 1.3 soft switch implementation..." |
183 |
cd $BUILD_DIR/ |
184 |
$install git-core autoconf automake autotools-dev pkg-config \ |
185 |
make gcc g++ libtool libc6-dev cmake libpcap-dev libxerces-c2-dev \ |
186 |
unzip libpcre3-dev flex bison libboost-dev |
187 |
|
188 |
if [ ! -d "ofsoftswitch13" ]; then |
189 |
git clone https://github.com/CPqD/ofsoftswitch13.git |
190 |
if [[ -n "$OF13_SWITCH_REV" ]]; then |
191 |
cd ofsoftswitch13 |
192 |
git checkout ${OF13_SWITCH_REV} |
193 |
cd .. |
194 |
fi |
195 |
fi |
196 |
|
197 |
# Install netbee |
198 |
if [ "$DIST" = "Ubuntu" ] && version_ge $RELEASE 14.04; then |
199 |
NBEESRC="nbeesrc-feb-24-2015" |
200 |
NBEEDIR="netbee" |
201 |
else |
202 |
NBEESRC="nbeesrc-jan-10-2013" |
203 |
NBEEDIR="nbeesrc-jan-10-2013" |
204 |
fi |
205 |
|
206 |
NBEEURL=${NBEEURL:-http://www.nbee.org/download/} |
207 |
wget -nc ${NBEEURL}${NBEESRC}.zip |
208 |
unzip ${NBEESRC}.zip |
209 |
cd ${NBEEDIR}/src |
210 |
cmake . |
211 |
make |
212 |
cd $BUILD_DIR/ |
213 |
sudo cp ${NBEEDIR}/bin/libn*.so /usr/local/lib |
214 |
sudo ldconfig |
215 |
sudo cp -R ${NBEEDIR}/include/ /usr/ |
216 |
|
217 |
# Resume the install: |
218 |
cd $BUILD_DIR/ofsoftswitch13 |
219 |
./boot.sh |
220 |
./configure |
221 |
make |
222 |
sudo make install |
223 |
cd $BUILD_DIR |
224 |
} |
225 |
|
226 |
|
227 |
function install_wireshark { |
228 |
if ! which wireshark; then |
229 |
echo "Installing Wireshark" |
230 |
if [ "$DIST" = "Fedora" -o "$DIST" = "RedHatEnterpriseServer" ]; then |
231 |
$install wireshark wireshark-gnome |
232 |
else |
233 |
$install wireshark tshark |
234 |
fi |
235 |
fi |
236 |
|
237 |
# Copy coloring rules: OF is white-on-blue: |
238 |
echo "Optionally installing wireshark color filters" |
239 |
mkdir -p $HOME/.wireshark |
240 |
cp -n $MININET_DIR/mininet/util/colorfilters $HOME/.wireshark |
241 |
|
242 |
echo "Checking Wireshark version" |
243 |
WSVER=`wireshark -v | egrep -o '[0-9\.]+' | head -1` |
244 |
if version_ge $WSVER 1.12; then |
245 |
echo "Wireshark version $WSVER >= 1.12 - returning" |
246 |
return |
247 |
fi |
248 |
|
249 |
echo "Cloning LoxiGen and building openflow.lua dissector" |
250 |
cd $BUILD_DIR |
251 |
git clone https://github.com/floodlight/loxigen.git |
252 |
cd loxigen |
253 |
make wireshark |
254 |
|
255 |
# Copy into plugin directory |
256 |
# libwireshark0/ on 11.04; libwireshark1/ on later |
257 |
WSDIR=`find /usr/lib -type d -name 'libwireshark*' | head -1` |
258 |
WSPLUGDIR=$WSDIR/plugins/ |
259 |
PLUGIN=loxi_output/wireshark/openflow.lua |
260 |
sudo cp $PLUGIN $WSPLUGDIR |
261 |
echo "Copied openflow plugin $PLUGIN to $WSPLUGDIR" |
262 |
|
263 |
cd $BUILD_DIR |
264 |
} |
265 |
|
266 |
|
267 |
# Install Open vSwitch specific version Ubuntu package |
268 |
function ubuntuOvs { |
269 |
echo "Creating and Installing Open vSwitch packages..." |
270 |
|
271 |
OVS_SRC=$BUILD_DIR/openvswitch |
272 |
OVS_TARBALL_LOC=http://openvswitch.org/releases |
273 |
|
274 |
if ! echo "$DIST" | egrep "Ubuntu|Debian" > /dev/null; then |
275 |
echo "OS must be Ubuntu or Debian" |
276 |
$cd BUILD_DIR |
277 |
return |
278 |
fi |
279 |
if [ "$DIST" = "Ubuntu" ] && ! version_ge $RELEASE 12.04; then |
280 |
echo "Ubuntu version must be >= 12.04" |
281 |
cd $BUILD_DIR |
282 |
return |
283 |
fi |
284 |
if [ "$DIST" = "Debian" ] && ! version_ge $RELEASE 7.0; then |
285 |
echo "Debian version must be >= 7.0" |
286 |
cd $BUILD_DIR |
287 |
return |
288 |
fi |
289 |
|
290 |
rm -rf $OVS_SRC |
291 |
mkdir -p $OVS_SRC |
292 |
cd $OVS_SRC |
293 |
|
294 |
if wget $OVS_TARBALL_LOC/openvswitch-$OVS_RELEASE.tar.gz 2> /dev/null; then |
295 |
tar xzf openvswitch-$OVS_RELEASE.tar.gz |
296 |
else |
297 |
echo "Failed to find OVS at $OVS_TARBALL_LOC/openvswitch-$OVS_RELEASE.tar.gz" |
298 |
cd $BUILD_DIR |
299 |
return |
300 |
fi |
301 |
|
302 |
# Remove any old packages |
303 |
$remove openvswitch-common openvswitch-datapath-dkms openvswitch-controller \ |
304 |
openvswitch-pki openvswitch-switch |
305 |
|
306 |
# Get build deps |
307 |
$install build-essential fakeroot debhelper autoconf automake libssl-dev \ |
308 |
pkg-config bzip2 openssl python-all procps python-qt4 \ |
309 |
python-zopeinterface python-twisted-conch dkms |
310 |
|
311 |
# Build OVS |
312 |
cd $BUILD_DIR/openvswitch/openvswitch-$OVS_RELEASE |
313 |
DEB_BUILD_OPTIONS='parallel=2 nocheck' fakeroot debian/rules binary |
314 |
cd .. |
315 |
$pkginst openvswitch-common_$OVS_RELEASE*.deb openvswitch-datapath-dkms_$OVS_RELEASE*.deb \ |
316 |
openvswitch-pki_$OVS_RELEASE*.deb openvswitch-switch_$OVS_RELEASE*.deb |
317 |
if $pkginst openvswitch-controller_$OVS_RELEASE*.deb; then |
318 |
echo "Ignoring error installing openvswitch-controller" |
319 |
fi |
320 |
|
321 |
modinfo openvswitch |
322 |
sudo ovs-vsctl show |
323 |
# Switch can run on its own, but |
324 |
# Mininet should control the controller |
325 |
# This appears to only be an issue on Ubuntu/Debian |
326 |
if sudo service openvswitch-controller stop; then |
327 |
echo "Stopped running controller" |
328 |
fi |
329 |
if [ -e /etc/init.d/openvswitch-controller ]; then |
330 |
sudo update-rc.d openvswitch-controller disable |
331 |
fi |
332 |
} |
333 |
|
334 |
|
335 |
# Install Open vSwitch |
336 |
|
337 |
function ovs { |
338 |
echo "Installing Open vSwitch..." |
339 |
|
340 |
if [ "$DIST" = "Fedora" -o "$DIST" = "RedHatEnterpriseServer" ]; then |
341 |
$install openvswitch openvswitch-controller |
342 |
return |
343 |
fi |
344 |
|
345 |
if [ "$DIST" = "Ubuntu" ] && ! version_ge $RELEASE 14.04; then |
346 |
# Older Ubuntu versions need openvswitch-datapath/-dkms |
347 |
# Manually installing openvswitch-datapath may be necessary |
348 |
# for manually built kernel .debs using Debian's defective kernel |
349 |
# packaging, which doesn't yield usable headers. |
350 |
if ! dpkg --get-selections | grep openvswitch-datapath; then |
351 |
# If you've already installed a datapath, assume you |
352 |
# know what you're doing and don't need dkms datapath. |
353 |
# Otherwise, install it. |
354 |
$install openvswitch-datapath-dkms |
355 |
fi |
356 |
fi |
357 |
|
358 |
$install openvswitch-switch |
359 |
if $install openvswitch-controller; then |
360 |
# Switch can run on its own, but |
361 |
# Mininet should control the controller |
362 |
# This appears to only be an issue on Ubuntu/Debian |
363 |
if sudo service openvswitch-controller stop; then |
364 |
echo "Stopped running controller" |
365 |
fi |
366 |
if [ -e /etc/init.d/openvswitch-controller ]; then |
367 |
sudo update-rc.d openvswitch-controller disable |
368 |
fi |
369 |
else |
370 |
echo "Attempting to install openvswitch-testcontroller" |
371 |
if ! $install openvswitch-testcontroller; then |
372 |
echo "Failed - skipping openvswitch-testcontroller" |
373 |
fi |
374 |
fi |
375 |
|
376 |
} |
377 |
|
378 |
function remove_ovs { |
379 |
pkgs=`dpkg --get-selections | grep openvswitch | awk '{ print $1;}'` |
380 |
echo "Removing existing Open vSwitch packages:" |
381 |
echo $pkgs |
382 |
if ! $remove $pkgs; then |
383 |
echo "Not all packages removed correctly" |
384 |
fi |
385 |
# For some reason this doesn't happen |
386 |
if scripts=`ls /etc/init.d/*openvswitch* 2>/dev/null`; then |
387 |
echo $scripts |
388 |
for s in $scripts; do |
389 |
s=$(basename $s) |
390 |
echo SCRIPT $s |
391 |
sudo service $s stop |
392 |
sudo rm -f /etc/init.d/$s |
393 |
sudo update-rc.d -f $s remove |
394 |
done |
395 |
fi |
396 |
echo "Done removing OVS" |
397 |
} |
398 |
|
399 |
function ivs { |
400 |
echo "Installing Indigo Virtual Switch..." |
401 |
|
402 |
IVS_SRC=$BUILD_DIR/ivs |
403 |
|
404 |
# Install dependencies |
405 |
$install git pkg-config gcc make libnl-3-dev libnl-route-3-dev libnl-genl-3-dev |
406 |
|
407 |
# Install IVS from source |
408 |
cd $BUILD_DIR |
409 |
git clone git://github.com/floodlight/ivs $IVS_SRC --recursive |
410 |
cd $IVS_SRC |
411 |
make |
412 |
sudo make install |
413 |
} |
414 |
|
415 |
# Install RYU |
416 |
function ryu { |
417 |
echo "Installing RYU..." |
418 |
|
419 |
# install Ryu dependencies" |
420 |
$install autoconf automake g++ libtool python make |
421 |
if [ "$DIST" = "Ubuntu" ]; then |
422 |
$install libxml2 libxslt-dev python-pip python-dev |
423 |
sudo pip install gevent |
424 |
elif [ "$DIST" = "Debian" ]; then |
425 |
$install libxml2 libxslt-dev python-pip python-dev |
426 |
sudo pip install gevent |
427 |
fi |
428 |
|
429 |
# if needed, update python-six |
430 |
SIX_VER=`pip show six | grep Version | awk '{print $2}'` |
431 |
if version_ge 1.7.0 $SIX_VER; then |
432 |
echo "Installing python-six version 1.7.0..." |
433 |
sudo pip install -I six==1.7.0 |
434 |
fi |
435 |
# fetch RYU |
436 |
cd $BUILD_DIR/ |
437 |
git clone git://github.com/osrg/ryu.git ryu |
438 |
cd ryu |
439 |
|
440 |
# install ryu |
441 |
sudo python ./setup.py install |
442 |
|
443 |
# Add symbolic link to /usr/bin |
444 |
sudo ln -s ./bin/ryu-manager /usr/local/bin/ryu-manager |
445 |
} |
446 |
|
447 |
# Install NOX with tutorial files |
448 |
function nox { |
449 |
echo "Installing NOX w/tutorial files..." |
450 |
|
451 |
# Install NOX deps: |
452 |
$install autoconf automake g++ libtool python python-twisted \ |
453 |
swig libssl-dev make |
454 |
if [ "$DIST" = "Debian" ]; then |
455 |
$install libboost1.35-dev |
456 |
elif [ "$DIST" = "Ubuntu" ]; then |
457 |
$install python-dev libboost-dev |
458 |
$install libboost-filesystem-dev |
459 |
$install libboost-test-dev |
460 |
fi |
461 |
# Install NOX optional deps: |
462 |
$install libsqlite3-dev python-simplejson |
463 |
|
464 |
# Fetch NOX destiny |
465 |
cd $BUILD_DIR/ |
466 |
git clone https://github.com/noxrepo/nox-classic.git noxcore |
467 |
cd noxcore |
468 |
if ! git checkout -b destiny remotes/origin/destiny ; then |
469 |
echo "Did not check out a new destiny branch - assuming current branch is destiny" |
470 |
fi |
471 |
|
472 |
# Apply patches |
473 |
git checkout -b tutorial-destiny |
474 |
git am $MININET_DIR/mininet/util/nox-patches/*tutorial-port-nox-destiny*.patch |
475 |
if [ "$DIST" = "Ubuntu" ] && version_ge $RELEASE 12.04; then |
476 |
git am $MININET_DIR/mininet/util/nox-patches/*nox-ubuntu12-hacks.patch |
477 |
fi |
478 |
|
479 |
# Build |
480 |
./boot.sh |
481 |
mkdir build |
482 |
cd build |
483 |
../configure |
484 |
make -j3 |
485 |
#make check |
486 |
|
487 |
# Add NOX_CORE_DIR env var: |
488 |
sed -i -e 's|# for examples$|&\nexport NOX_CORE_DIR=$BUILD_DIR/noxcore/build/src|' ~/.bashrc |
489 |
|
490 |
# To verify this install: |
491 |
#cd ~/noxcore/build/src |
492 |
#./nox_core -v -i ptcp: |
493 |
} |
494 |
|
495 |
# Install NOX Classic/Zaku for OpenFlow 1.3 |
496 |
function nox13 { |
497 |
echo "Installing NOX w/tutorial files..." |
498 |
|
499 |
# Install NOX deps: |
500 |
$install autoconf automake g++ libtool python python-twisted \ |
501 |
swig libssl-dev make |
502 |
if [ "$DIST" = "Debian" ]; then |
503 |
$install libboost1.35-dev |
504 |
elif [ "$DIST" = "Ubuntu" ]; then |
505 |
$install python-dev libboost-dev |
506 |
$install libboost-filesystem-dev |
507 |
$install libboost-test-dev |
508 |
fi |
509 |
|
510 |
# Fetch NOX destiny |
511 |
cd $BUILD_DIR/ |
512 |
git clone https://github.com/CPqD/nox13oflib.git |
513 |
cd nox13oflib |
514 |
|
515 |
# Build |
516 |
./boot.sh |
517 |
mkdir build |
518 |
cd build |
519 |
../configure |
520 |
make -j3 |
521 |
#make check |
522 |
|
523 |
# To verify this install: |
524 |
#cd ~/nox13oflib/build/src |
525 |
#./nox_core -v -i ptcp: |
526 |
} |
527 |
|
528 |
|
529 |
# "Install" POX |
530 |
function pox { |
531 |
echo "Installing POX into $BUILD_DIR/pox..." |
532 |
cd $BUILD_DIR |
533 |
git clone https://github.com/noxrepo/pox.git |
534 |
} |
535 |
|
536 |
# Install OFtest |
537 |
function oftest { |
538 |
echo "Installing oftest..." |
539 |
|
540 |
# Install deps: |
541 |
$install tcpdump python-scapy |
542 |
|
543 |
# Install oftest: |
544 |
cd $BUILD_DIR/ |
545 |
git clone git://github.com/floodlight/oftest |
546 |
} |
547 |
|
548 |
# Install cbench |
549 |
function cbench { |
550 |
echo "Installing cbench..." |
551 |
|
552 |
if [ "$DIST" = "Fedora" -o "$DIST" = "RedHatEnterpriseServer" ]; then |
553 |
$install net-snmp-devel libpcap-devel libconfig-devel |
554 |
else |
555 |
$install libsnmp-dev libpcap-dev libconfig-dev |
556 |
fi |
557 |
cd $BUILD_DIR/ |
558 |
# was: git clone git://gitosis.stanford.edu/oflops.git |
559 |
# Use our own fork on github for now: |
560 |
git clone git://github.com/mininet/oflops |
561 |
cd oflops |
562 |
sh boot.sh || true # possible error in autoreconf, so run twice |
563 |
sh boot.sh |
564 |
./configure --with-openflow-src-dir=$BUILD_DIR/openflow |
565 |
make |
566 |
sudo make install || true # make install fails; force past this |
567 |
} |
568 |
|
569 |
function vm_other { |
570 |
echo "Doing other Mininet VM setup tasks..." |
571 |
|
572 |
# Remove avahi-daemon, which may cause unwanted discovery packets to be |
573 |
# sent during tests, near link status changes: |
574 |
echo "Removing avahi-daemon" |
575 |
$remove avahi-daemon |
576 |
|
577 |
# was: Disable IPv6. Add to /etc/modprobe.d/blacklist: |
578 |
#echo "Attempting to disable IPv6" |
579 |
#if [ "$DIST" = "Ubuntu" ]; then |
580 |
# BLACKLIST=/etc/modprobe.d/blacklist.conf |
581 |
#else |
582 |
# BLACKLIST=/etc/modprobe.d/blacklist |
583 |
#fi |
584 |
#sudo sh -c "echo 'blacklist net-pf-10\nblacklist ipv6' >> $BLACKLIST" |
585 |
echo "Disabling IPv6" |
586 |
# Disable IPv6 |
587 |
if ! grep 'disable_ipv6' /etc/sysctl.conf; then |
588 |
echo 'Disabling IPv6' |
589 |
echo ' |
590 |
# Mininet: disable IPv6 |
591 |
net.ipv6.conf.all.disable_ipv6 = 1 |
592 |
net.ipv6.conf.default.disable_ipv6 = 1 |
593 |
net.ipv6.conf.lo.disable_ipv6 = 1' | sudo tee -a /etc/sysctl.conf > /dev/null |
594 |
fi |
595 |
# Since the above doesn't disable neighbor discovery, also do this: |
596 |
if ! grep 'ipv6.disable' /etc/default/grub; then |
597 |
sudo sed -i -e \ |
598 |
's/GRUB_CMDLINE_LINUX_DEFAULT="/GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1 /' \ |
599 |
/etc/default/grub |
600 |
sudo update-grub |
601 |
fi |
602 |
# Disabling IPv6 breaks X11 forwarding via ssh |
603 |
line='AddressFamily inet' |
604 |
file='/etc/ssh/sshd_config' |
605 |
echo "Adding $line to $file" |
606 |
if ! grep "$line" $file > /dev/null; then |
607 |
echo "$line" | sudo tee -a $file > /dev/null |
608 |
fi |
609 |
|
610 |
# Enable command auto completion using sudo; modify ~/.bashrc: |
611 |
sed -i -e 's|# for examples$|&\ncomplete -cf sudo|' ~/.bashrc |
612 |
|
613 |
# Install tcpdump, cmd-line packet dump tool. Also install gitk, |
614 |
# a graphical git history viewer. |
615 |
$install tcpdump gitk |
616 |
|
617 |
# Install common text editors |
618 |
$install vim nano emacs |
619 |
|
620 |
# Install NTP |
621 |
$install ntp |
622 |
|
623 |
# Install vconfig for VLAN example |
624 |
if [ "$DIST" = "Fedora" -o "$DIST" = "RedHatEnterpriseServer" ]; then |
625 |
$install vconfig |
626 |
else |
627 |
$install vlan |
628 |
fi |
629 |
|
630 |
# Set git to colorize everything. |
631 |
git config --global color.diff auto |
632 |
git config --global color.status auto |
633 |
git config --global color.branch auto |
634 |
|
635 |
# Reduce boot screen opt-out delay. Modify timeout in /boot/grub/menu.lst to 1: |
636 |
if [ "$DIST" = "Debian" ]; then |
637 |
sudo sed -i -e 's/^timeout.*$/timeout 1/' /boot/grub/menu.lst |
638 |
fi |
639 |
|
640 |
# Clean unneeded debs: |
641 |
rm -f ~/linux-headers-* ~/linux-image-* |
642 |
} |
643 |
|
644 |
# Script to copy built OVS kernel module to where modprobe will |
645 |
# find them automatically. Removes the need to keep an environment variable |
646 |
# for insmod usage, and works nicely with multiple kernel versions. |
647 |
# |
648 |
# The downside is that after each recompilation of OVS you'll need to |
649 |
# re-run this script. If you're using only one kernel version, then it may be |
650 |
# a good idea to use a symbolic link in place of the copy below. |
651 |
function modprobe { |
652 |
echo "Setting up modprobe for OVS kmod..." |
653 |
set +o nounset |
654 |
if [ -z "$OVS_KMODS" ]; then |
655 |
echo "OVS_KMODS not set. Aborting." |
656 |
else |
657 |
sudo cp $OVS_KMODS $DRIVERS_DIR |
658 |
sudo depmod -a ${KERNEL_NAME} |
659 |
fi |
660 |
set -o nounset |
661 |
} |
662 |
|
663 |
function all { |
664 |
if [ "$DIST" = "Fedora" ]; then |
665 |
printf "\nFedora 18+ support (still work in progress):\n" |
666 |
printf " * Fedora 18+ has kernel 3.10 RPMS in the updates repositories\n" |
667 |
printf " * Fedora 18+ has openvswitch 1.10 RPMS in the updates repositories\n" |
668 |
printf " * the install.sh script options [-bfnpvw] should work.\n" |
669 |
printf " * for a basic setup just try:\n" |
670 |
printf " install.sh -fnpv\n\n" |
671 |
exit 3 |
672 |
fi |
673 |
echo "Installing all packages except for -eix (doxypy, ivs, nox-classic)..." |
674 |
kernel |
675 |
mn_deps |
676 |
# Skip mn_dev (doxypy/texlive/fonts/etc.) because it's huge |
677 |
# mn_dev |
678 |
of |
679 |
install_wireshark |
680 |
ovs |
681 |
# We may add ivs once it's more mature |
682 |
# ivs |
683 |
# NOX-classic is deprecated, but you can install it manually if desired. |
684 |
# nox |
685 |
pox |
686 |
oftest |
687 |
cbench |
688 |
echo "Enjoy Mininet!" |
689 |
} |
690 |
|
691 |
# Restore disk space and remove sensitive files before shipping a VM. |
692 |
function vm_clean { |
693 |
echo "Cleaning VM..." |
694 |
sudo apt-get clean |
695 |
sudo apt-get autoremove |
696 |
sudo rm -rf /tmp/* |
697 |
sudo rm -rf openvswitch*.tar.gz |
698 |
|
699 |
# Remove sensistive files |
700 |
history -c # note this won't work if you have multiple bash sessions |
701 |
rm -f ~/.bash_history # need to clear in memory and remove on disk |
702 |
rm -f ~/.ssh/id_rsa* ~/.ssh/known_hosts |
703 |
sudo rm -f ~/.ssh/authorized_keys* |
704 |
|
705 |
# Remove Mininet files |
706 |
#sudo rm -f /lib/modules/python2.5/site-packages/mininet* |
707 |
#sudo rm -f /usr/bin/mnexec |
708 |
|
709 |
# Clear optional dev script for SSH keychain load on boot |
710 |
rm -f ~/.bash_profile |
711 |
|
712 |
# Clear git changes |
713 |
git config --global user.name "None" |
714 |
git config --global user.email "None" |
715 |
|
716 |
# Note: you can shrink the .vmdk in vmware using |
717 |
# vmware-vdiskmanager -k *.vmdk |
718 |
echo "Zeroing out disk blocks for efficient compaction..." |
719 |
time sudo dd if=/dev/zero of=/tmp/zero bs=1M |
720 |
sync ; sleep 1 ; sync ; sudo rm -f /tmp/zero |
721 |
|
722 |
} |
723 |
|
724 |
function usage { |
725 |
printf '\nUsage: %s [-abcdfhikmnprtvVwxy03]\n\n' $(basename $0) >&2 |
726 |
|
727 |
printf 'This install script attempts to install useful packages\n' >&2 |
728 |
printf 'for Mininet. It should (hopefully) work on Ubuntu 11.10+\n' >&2 |
729 |
printf 'If you run into trouble, try\n' >&2 |
730 |
printf 'installing one thing at a time, and looking at the \n' >&2 |
731 |
printf 'specific installation function in this script.\n\n' >&2 |
732 |
|
733 |
printf 'options:\n' >&2 |
734 |
printf -- ' -a: (default) install (A)ll packages - good luck!\n' >&2 |
735 |
printf -- ' -b: install controller (B)enchmark (oflops)\n' >&2 |
736 |
printf -- ' -c: (C)lean up after kernel install\n' >&2 |
737 |
printf -- ' -d: (D)elete some sensitive files from a VM image\n' >&2 |
738 |
printf -- ' -e: install Mininet d(E)veloper dependencies\n' >&2 |
739 |
printf -- ' -f: install Open(F)low\n' >&2 |
740 |
printf -- ' -h: print this (H)elp message\n' >&2 |
741 |
printf -- ' -i: install (I)ndigo Virtual Switch\n' >&2 |
742 |
printf -- ' -k: install new (K)ernel\n' >&2 |
743 |
printf -- ' -m: install Open vSwitch kernel (M)odule from source dir\n' >&2 |
744 |
printf -- ' -n: install Mini(N)et dependencies + core files\n' >&2 |
745 |
printf -- ' -p: install (P)OX OpenFlow Controller\n' >&2 |
746 |
printf -- ' -r: remove existing Open vSwitch packages\n' >&2 |
747 |
printf -- ' -s <dir>: place dependency (S)ource/build trees in <dir>\n' >&2 |
748 |
printf -- ' -t: complete o(T)her Mininet VM setup tasks\n' >&2 |
749 |
printf -- ' -v: install Open (V)switch\n' >&2 |
750 |
printf -- ' -V <version>: install a particular version of Open (V)switch on Ubuntu\n' >&2 |
751 |
printf -- ' -w: install OpenFlow (W)ireshark dissector\n' >&2 |
752 |
printf -- ' -y: install R(y)u Controller\n' >&2 |
753 |
printf -- ' -x: install NO(X) Classic OpenFlow controller\n' >&2 |
754 |
printf -- ' -0: (default) -0[fx] installs OpenFlow 1.0 versions\n' >&2 |
755 |
printf -- ' -3: -3[fx] installs OpenFlow 1.3 versions\n' >&2 |
756 |
exit 2 |
757 |
} |
758 |
|
759 |
OF_VERSION=1.0 |
760 |
|
761 |
if [ $# -eq 0 ] |
762 |
then |
763 |
all |
764 |
else |
765 |
while getopts 'abcdefhikmnprs:tvV:wxy03' OPTION |
766 |
do |
767 |
case $OPTION in |
768 |
a) all;; |
769 |
b) cbench;; |
770 |
c) kernel_clean;; |
771 |
d) vm_clean;; |
772 |
e) mn_dev;; |
773 |
f) case $OF_VERSION in |
774 |
1.0) of;; |
775 |
1.3) of13;; |
776 |
*) echo "Invalid OpenFlow version $OF_VERSION";; |
777 |
esac;; |
778 |
h) usage;; |
779 |
i) ivs;; |
780 |
k) kernel;; |
781 |
m) modprobe;; |
782 |
n) mn_deps;; |
783 |
p) pox;; |
784 |
r) remove_ovs;; |
785 |
s) mkdir -p $OPTARG; # ensure the directory is created |
786 |
BUILD_DIR="$( cd -P "$OPTARG" && pwd )"; # get the full path |
787 |
echo "Dependency installation directory: $BUILD_DIR";; |
788 |
t) vm_other;; |
789 |
v) ovs;; |
790 |
V) OVS_RELEASE=$OPTARG; |
791 |
ubuntuOvs;; |
792 |
w) install_wireshark;; |
793 |
x) case $OF_VERSION in |
794 |
1.0) nox;; |
795 |
1.3) nox13;; |
796 |
*) echo "Invalid OpenFlow version $OF_VERSION";; |
797 |
esac;; |
798 |
y) ryu;; |
799 |
0) OF_VERSION=1.0;; |
800 |
3) OF_VERSION=1.3;; |
801 |
?) usage;; |
802 |
esac |
803 |
done |
804 |
shift $(($OPTIND - 1)) |
805 |
fi |