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