Statistics
| Branch: | Tag: | Revision:

mininet / util / install.sh @ b5552773

History | View | Annotate | Download (20.6 KB)

1
#!/usr/bin/env bash
2

    
3
# Mininet install script for Ubuntu (and Debian Lenny)
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 )"
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
19
case $PWD in
20
  $MININET_DIR/*) BUILD_DIR=$MININET_DIR;; # currect directory is a subdirectory
21
  *) BUILD_DIR=$PWD;;
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
    if ! which bc &> /dev/null; then
47
        $install bc
48
    fi
49
fi
50
if which lsb_release &> /dev/null; then
51
    DIST=`lsb_release -is`
52
    RELEASE=`lsb_release -rs`
53
    CODENAME=`lsb_release -cs`
54
fi
55
echo "Detected Linux distribution: $DIST $RELEASE $CODENAME $ARCH"
56

    
57
# Kernel params
58

    
59
if [ "$DIST" = "Ubuntu" ]; then
60
    if [ "$RELEASE" = "10.04" ]; then
61
        KERNEL_NAME='3.0.0-15-generic'
62
    else
63
        KERNEL_NAME=`uname -r`
64
    fi
65
    KERNEL_HEADERS=linux-headers-${KERNEL_NAME}
66
elif [ "$DIST" = "Debian" ] && [ "$ARCH" = "i386" ] && [ "$CODENAME" = "lenny" ]; then
67
    KERNEL_NAME=2.6.33.1-mininet
68
    KERNEL_HEADERS=linux-headers-${KERNEL_NAME}_${KERNEL_NAME}-10.00.Custom_i386.deb
69
    KERNEL_IMAGE=linux-image-${KERNEL_NAME}_${KERNEL_NAME}-10.00.Custom_i386.deb
70
else
71
    echo "Install.sh currently only supports Ubuntu and Debian Lenny i386."
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
# Kernel Deb pkg to be removed:
79
KERNEL_IMAGE_OLD=linux-image-2.6.26-33-generic
80

    
81
DRIVERS_DIR=/lib/modules/${KERNEL_NAME}/kernel/drivers/net
82

    
83
OVS_RELEASE=1.4.0
84
OVS_PACKAGE_LOC=https://github.com/downloads/mininet/mininet
85
OVS_BUILDSUFFIX=-ignore # was -2
86
OVS_PACKAGE_NAME=ovs-$OVS_RELEASE-core-$DIST_LC-$RELEASE-$ARCH$OVS_BUILDSUFFIX.tar
87
OVS_SRC=$BUILD_DIR/openvswitch
88
OVS_TAG=v$OVS_RELEASE
89
OVS_BUILD=$OVS_SRC/build-$KERNEL_NAME
90
OVS_KMODS=($OVS_BUILD/datapath/linux/{openvswitch_mod.ko,brcompat_mod.ko})
91

    
92
function kernel {
93
    echo "Install Mininet-compatible kernel if necessary"
94
    sudo apt-get update
95
    if [ "$DIST" = "Ubuntu" ] &&  [ "$RELEASE" = "10.04" ]; then
96
        $install linux-image-$KERNEL_NAME
97
    elif [ "$DIST" = "Debian" ]; then
98
        # The easy approach: download pre-built linux-image and linux-headers packages:
99
        wget -c $KERNEL_LOC/$KERNEL_HEADERS
100
        wget -c $KERNEL_LOC/$KERNEL_IMAGE
101

    
102
        # Install custom linux headers and image:
103
        $pkginst $KERNEL_IMAGE $KERNEL_HEADERS
104

    
105
        # The next two steps are to work around a bug in newer versions of
106
        # kernel-package, which fails to add initrd images with the latest kernels.
107
        # See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525032
108
        # Generate initrd image if the .deb didn't install it:
109
        if ! test -e /boot/initrd.img-${KERNEL_NAME}; then
110
            sudo update-initramfs -c -k ${KERNEL_NAME}
111
        fi
112

    
113
        # Ensure /boot/grub/menu.lst boots with initrd image:
114
        sudo update-grub
115

    
116
        # The default should be the new kernel. Otherwise, you may need to modify
117
        # /boot/grub/menu.lst to set the default to the entry corresponding to the
118
        # kernel you just installed.
119
    fi
120
}
121

    
122
function kernel_clean {
123
    echo "Cleaning kernel..."
124

    
125
    # To save disk space, remove previous kernel
126
    if ! $remove $KERNEL_IMAGE_OLD; then
127
        echo $KERNEL_IMAGE_OLD not installed.
128
    fi
129

    
130
    # Also remove downloaded packages:
131
    rm -f $HOME/linux-headers-* $HOME/linux-image-*
132
}
133

    
134
# Install Mininet deps
135
function mn_deps {
136
    echo "Installing Mininet dependencies"
137
    $install gcc make socat psmisc xterm ssh iperf iproute telnet \
138
        python-setuptools cgroup-bin ethtool help2man \
139
        pyflakes pylint pep8
140

    
141
    # Add sysctl parameters as noted in the INSTALL file to increase kernel
142
    # limits to support larger setups:
143
    if ! grep Mininet /etc/sysctl.conf; then
144
        echo "Adding Mininet sysctl settings"
145
        sudo su -c "cat $MININET_DIR/mininet/util/sysctl_addon >> /etc/sysctl.conf"
146
    fi
147
    # Load new sysctl settings:
148
    sudo sysctl -p
149

    
150
    echo "Installing Mininet core"
151
    pushd $MININET_DIR/mininet
152
    sudo make install
153
    popd
154
}
155

    
156
# The following will cause a full OF install, covering:
157
# -user switch
158
# The instructions below are an abbreviated version from
159
# http://www.openflowswitch.org/wk/index.php/Debian_Install
160
# ... modified to use Debian Lenny rather than unstable.
161
function of {
162
    echo "Installing OpenFlow reference implementation..."
163
    cd $BUILD_DIR/
164
    $install git-core autoconf automake autotools-dev pkg-config \
165
		make gcc libtool libc6-dev
166
    git clone git://openflowswitch.org/openflow.git
167
    cd $BUILD_DIR/openflow
168

    
169
    # Patch controller to handle more than 16 switches
170
    patch -p1 < $MININET_DIR/mininet/util/openflow-patches/controller.patch
171

    
172
    # Resume the install:
173
    ./boot.sh
174
    ./configure
175
    make
176
    sudo make install
177
    cd $BUILD_DIR
178
}
179

    
180
function of13 {
181
    echo "Installing OpenFlow 1.3 soft switch implementation..."
182
    cd $BUILD_DIR/
183
    $install  git-core autoconf automake autotools-dev pkg-config \
184
        make gcc g++ libtool libc6-dev cmake libpcap-dev libxerces-c2-dev  \
185
        unzip libpcre3-dev flex bison libboost-dev
186

    
187
    if [ ! -d "ofsoftswitch13" ]; then
188
         git clone https://github.com/CPqD/ofsoftswitch13.git
189
    fi
190

    
191
    # Install netbee
192
    NBEESRC="nbeesrc-jan-10-2013"
193
    NBEEURL=${NBEEURL:-http://www.nbee.org/download/}
194
    wget -nc ${NBEEURL}${NBEESRC}.zip
195
    unzip ${NBEESRC}.zip
196
    cd ${NBEESRC}/src
197
    cmake .
198
    make
199
    cd $BUILD_DIR/
200
    sudo cp ${NBEESRC}/bin/libn*.so /usr/local/lib
201
    sudo ldconfig
202
    sudo cp -R ${NBEESRC}/include/ /usr/
203

    
204
    # Resume the install:
205
    cd $BUILD_DIR/ofsoftswitch13
206
    ./boot.sh
207
    ./configure
208
    make
209
    sudo make install
210
    cd $BUILD_DIR
211
}
212

    
213
function wireshark {
214
    echo "Installing Wireshark dissector..."
215

    
216
    sudo apt-get install -y wireshark tshark libgtk2.0-dev
217

    
218
    if [ "$DIST" = "Ubuntu" ] && [ "$RELEASE" != "10.04" ]; then
219
        # Install newer version
220
        sudo apt-get install -y scons mercurial libglib2.0-dev
221
        sudo apt-get install -y libwiretap-dev libwireshark-dev
222
        cd $BUILD_DIR
223
        hg clone https://bitbucket.org/barnstorm/of-dissector
224
        cd of-dissector
225
        if [[ -n "$WS_DISSECTOR_REV" ]]; then
226
            hg checkout ${WS_DISSECTOR_REV}
227
        fi
228
        cd src
229
        export WIRESHARK=/usr/include/wireshark
230
        scons
231
        # libwireshark0/ on 11.04; libwireshark1/ on later
232
        WSDIR=`ls -d /usr/lib/wireshark/libwireshark* | head -1`
233
        WSPLUGDIR=$WSDIR/plugins/
234
        sudo cp openflow.so $WSPLUGDIR
235
        echo "Copied openflow plugin to $WSPLUGDIR"
236
    else
237
        # Install older version from reference source
238
        cd $BUILD_DIR/openflow/utilities/wireshark_dissectors/openflow
239
        make
240
        sudo make install
241
    fi
242

    
243
    # Copy coloring rules: OF is white-on-blue:
244
    mkdir -p $HOME/.wireshark
245
    cp $MININET_DIR/mininet/util/colorfilters $HOME/.wireshark
246
}
247

    
248

    
249
# Install Open vSwitch
250
# Instructions derived from OVS INSTALL, INSTALL.OpenFlow and README files.
251

    
252
function ovs {
253
    echo "Installing Open vSwitch..."
254

    
255
    # Required for module build/dkms install
256
    $install $KERNEL_HEADERS
257

    
258
    ovspresent=0
259

    
260
    # First see if we have packages
261
    # XXX wget -c seems to fail from github/amazon s3
262
    cd /tmp
263
    if wget $OVS_PACKAGE_LOC/$OVS_PACKAGE_NAME 2> /dev/null; then
264
	$install patch dkms fakeroot python-argparse
265
        tar xf $OVS_PACKAGE_NAME
266
        orig=`tar tf $OVS_PACKAGE_NAME`
267
        # Now install packages in reasonable dependency order
268
        order='dkms common pki openvswitch-switch brcompat controller'
269
        pkgs=""
270
        for p in $order; do
271
            pkg=`echo "$orig" | grep $p`
272
	    # Annoyingly, things seem to be missing without this flag
273
            $pkginst --force-confmiss $pkg
274
        done
275
        ovspresent=1
276
    fi
277

    
278
    # Otherwise try distribution's OVS packages
279
    if [ "$DIST" = "Ubuntu" ] && [ `expr $RELEASE '>=' 11.10` = 1 ]; then
280
        if ! dpkg --get-selections | grep openvswitch-datapath; then
281
            # If you've already installed a datapath, assume you
282
            # know what you're doing and don't need dkms datapath.
283
            # Otherwise, install it.
284
            $install openvswitch-datapath-dkms
285
        fi
286
	if $install openvswitch-switch openvswitch-controller; then
287
            echo "Ignoring error installing openvswitch-controller"
288
        fi
289
        ovspresent=1
290
    fi
291

    
292
    # Switch can run on its own, but
293
    # Mininet should control the controller
294
    if [ -e /etc/init.d/openvswitch-controller ]; then
295
        if sudo service openvswitch-controller stop; then
296
            echo "Stopped running controller"
297
        fi
298
        sudo update-rc.d openvswitch-controller disable
299
    fi
300

    
301
    if [ $ovspresent = 1 ]; then
302
        echo "Done (hopefully) installing packages"
303
        cd $BUILD_DIR
304
        return
305
    fi
306

    
307
    # Otherwise attempt to install from source
308

    
309
    $install pkg-config gcc make python-dev libssl-dev libtool
310

    
311
    if [ "$DIST" = "Debian" ]; then
312
        if [ "$CODENAME" = "lenny" ]; then
313
            $install git-core
314
            # Install Autoconf 2.63+ backport from Debian Backports repo:
315
            # Instructions from http://backports.org/dokuwiki/doku.php?id=instructions
316
            sudo su -c "echo 'deb http://www.backports.org/debian lenny-backports main contrib non-free' >> /etc/apt/sources.list"
317
            sudo apt-get update
318
            sudo apt-get -y --force-yes install debian-backports-keyring
319
            sudo apt-get -y --force-yes -t lenny-backports install autoconf
320
        fi
321
    else
322
        $install git
323
    fi
324

    
325
    # Install OVS from release
326
    cd $BUILD_DIR/
327
    git clone git://openvswitch.org/openvswitch $OVS_SRC
328
    cd $OVS_SRC
329
    git checkout $OVS_TAG
330
    ./boot.sh
331
    BUILDDIR=/lib/modules/${KERNEL_NAME}/build
332
    if [ ! -e $BUILDDIR ]; then
333
        echo "Creating build sdirectory $BUILDDIR"
334
        sudo mkdir -p $BUILDDIR
335
    fi
336
    opts="--with-linux=$BUILDDIR"
337
    mkdir -p $OVS_BUILD
338
    cd $OVS_BUILD
339
    ../configure $opts
340
    make
341
    sudo make install
342

    
343
    modprobe
344
}
345

    
346
function remove_ovs {
347
    pkgs=`dpkg --get-selections | grep openvswitch | awk '{ print $1;}'`
348
    echo "Removing existing Open vSwitch packages:"
349
    echo $pkgs
350
    if ! $remove $pkgs; then
351
        echo "Not all packages removed correctly"
352
    fi
353
    # For some reason this doesn't happen
354
    if scripts=`ls /etc/init.d/*openvswitch* 2>/dev/null`; then
355
        echo $scripts
356
        for s in $scripts; do
357
            s=$(basename $s)
358
            echo SCRIPT $s
359
            sudo service $s stop
360
            sudo rm -f /etc/init.d/$s
361
            sudo update-rc.d -f $s remove
362
        done
363
    fi
364
    echo "Done removing OVS"
365
}
366

    
367
# Install NOX with tutorial files
368
function nox {
369
    echo "Installing NOX w/tutorial files..."
370

    
371
    # Install NOX deps:
372
    $install autoconf automake g++ libtool python python-twisted \
373
		swig libssl-dev make
374
    if [ "$DIST" = "Debian" ]; then
375
        $install libboost1.35-dev
376
    elif [ "$DIST" = "Ubuntu" ]; then
377
        $install python-dev libboost-dev
378
        $install libboost-filesystem-dev
379
        $install libboost-test-dev
380
    fi
381
    # Install NOX optional deps:
382
    $install libsqlite3-dev python-simplejson
383

    
384
    # Fetch NOX destiny
385
    cd $BUILD_DIR/
386
    git clone https://github.com/noxrepo/nox-classic.git noxcore
387
    cd noxcore
388
    if ! git checkout -b destiny remotes/origin/destiny ; then
389
        echo "Did not check out a new destiny branch - assuming current branch is destiny"
390
    fi
391

    
392
    # Apply patches
393
    git checkout -b tutorial-destiny
394
    git am $MININET_DIR/mininet/util/nox-patches/*tutorial-port-nox-destiny*.patch
395
    if [ "$DIST" = "Ubuntu" ] && [ `expr $RELEASE '>=' 12.04` = 1 ]; then
396
        git am $MININET_DIR/mininet/util/nox-patches/*nox-ubuntu12-hacks.patch
397
    fi
398

    
399
    # Build
400
    ./boot.sh
401
    mkdir build
402
    cd build
403
    ../configure
404
    make -j3
405
    #make check
406

    
407
    # Add NOX_CORE_DIR env var:
408
    sed -i -e 's|# for examples$|&\nexport NOX_CORE_DIR=$BUILD_DIR/noxcore/build/src|' ~/.bashrc
409

    
410
    # To verify this install:
411
    #cd ~/noxcore/build/src
412
    #./nox_core -v -i ptcp:
413
}
414

    
415
# Install NOX Classic/Zaku for OpenFlow 1.3
416
function nox13 {
417
    echo "Installing NOX w/tutorial files..."
418

    
419
    # Install NOX deps:
420
    $install autoconf automake g++ libtool python python-twisted \
421
        swig libssl-dev make
422
    if [ "$DIST" = "Debian" ]; then
423
        $install libboost1.35-dev
424
    elif [ "$DIST" = "Ubuntu" ]; then
425
        $install python-dev libboost-dev
426
        $install libboost-filesystem-dev
427
        $install libboost-test-dev
428
    fi
429

    
430
    # Fetch NOX destiny
431
    cd $BUILD_DIR/
432
    git clone https://github.com/CPqD/nox13oflib.git
433
    cd nox13oflib
434

    
435
    # Build
436
    ./boot.sh
437
    mkdir build
438
    cd build
439
    ../configure
440
    make -j3
441
    #make check
442

    
443
    # To verify this install:
444
    #cd ~/nox13oflib/build/src
445
    #./nox_core -v -i ptcp:
446
}
447

    
448

    
449
# "Install" POX
450
function pox {
451
    echo "Installing POX into $BUILD_DIR/pox..."
452
    cd $BUILD_DIR
453
    git clone https://github.com/noxrepo/pox.git
454
}
455

    
456
# Install OFtest
457
function oftest {
458
    echo "Installing oftest..."
459

    
460
    # Install deps:
461
    $install tcpdump python-scapy
462

    
463
    # Install oftest:
464
    cd $BUILD_DIR/
465
    git clone git://github.com/floodlight/oftest
466
}
467

    
468
# Install cbench
469
function cbench {
470
    echo "Installing cbench..."
471

    
472
    $install libsnmp-dev libpcap-dev libconfig-dev
473
    cd $BUILD_DIR/
474
    git clone git://openflow.org/oflops.git
475
    cd oflops
476
    sh boot.sh || true # possible error in autoreconf, so run twice
477
    sh boot.sh
478
    ./configure --with-openflow-src-dir=$BUILD_DIR/openflow
479
    make
480
    sudo make install || true # make install fails; force past this
481
}
482

    
483
function vm_other {
484
    echo "Doing other Mininet VM setup tasks..."
485

    
486
    # Remove avahi-daemon, which may cause unwanted discovery packets to be
487
    # sent during tests, near link status changes:
488
    echo "Removing avahi-daemon"
489
    $remove avahi-daemon
490

    
491
    # was: Disable IPv6.  Add to /etc/modprobe.d/blacklist:
492
    #echo "Attempting to disable IPv6"
493
    #if [ "$DIST" = "Ubuntu" ]; then
494
    #    BLACKLIST=/etc/modprobe.d/blacklist.conf
495
    #else
496
    #    BLACKLIST=/etc/modprobe.d/blacklist
497
    #fi
498
    #sudo sh -c "echo 'blacklist net-pf-10\nblacklist ipv6' >> $BLACKLIST"
499

    
500
    # Disable IPv6
501
    if ! grep 'disable IPv6' /etc/sysctl.conf; then
502
        echo 'Disabling IPv6'
503
        echo '
504
# Mininet: disable IPv6
505
net.ipv6.conf.all.disable_ipv6 = 1
506
net.ipv6.conf.default.disable_ipv6 = 1
507
net.ipv6.conf.lo.disable_ipv6 = 1' | sudo tee -a /etc/sysctl.conf > /dev/null
508
    fi
509
    # Disabling IPv6 breaks X11 forwarding via ssh
510
    line='AddressFamily inet'
511
    file='/etc/ssh/sshd_config'
512
    echo "Adding $line to $file"
513
    if ! grep "$line" $file > /dev/null; then
514
        echo "$line" | sudo tee -a $file > /dev/null
515
    fi
516

    
517
    # Enable command auto completion using sudo; modify ~/.bashrc:
518
    sed -i -e 's|# for examples$|&\ncomplete -cf sudo|' ~/.bashrc
519

    
520
    # Install tcpdump, cmd-line packet dump tool.  Also install gitk,
521
    # a graphical git history viewer.
522
    $install tcpdump gitk
523

    
524
    # Install common text editors
525
    $install vim nano emacs
526

    
527
    # Install NTP
528
    $install ntp
529

    
530
    # Set git to colorize everything.
531
    git config --global color.diff auto
532
    git config --global color.status auto
533
    git config --global color.branch auto
534

    
535
    # Reduce boot screen opt-out delay. Modify timeout in /boot/grub/menu.lst to 1:
536
    if [ "$DIST" = "Debian" ]; then
537
        sudo sed -i -e 's/^timeout.*$/timeout         1/' /boot/grub/menu.lst
538
    fi
539

    
540
    # Clean unneeded debs:
541
    rm -f ~/linux-headers-* ~/linux-image-*
542
}
543

    
544
# Script to copy built OVS kernel module to where modprobe will
545
# find them automatically.  Removes the need to keep an environment variable
546
# for insmod usage, and works nicely with multiple kernel versions.
547
#
548
# The downside is that after each recompilation of OVS you'll need to
549
# re-run this script.  If you're using only one kernel version, then it may be
550
# a good idea to use a symbolic link in place of the copy below.
551
function modprobe {
552
    echo "Setting up modprobe for OVS kmod..."
553

    
554
    sudo cp $OVS_KMODS $DRIVERS_DIR
555
    sudo depmod -a ${KERNEL_NAME}
556
}
557

    
558
function all {
559
    echo "Running all commands..."
560
    kernel
561
    mn_deps
562
    of
563
    wireshark
564
    ovs
565
    # NOX-classic is deprecated, but you can install it manually if desired.
566
    # nox
567
    pox
568
    oftest
569
    cbench
570
    echo "Enjoy Mininet!"
571
}
572

    
573
# Restore disk space and remove sensitive files before shipping a VM.
574
function vm_clean {
575
    echo "Cleaning VM..."
576
    sudo apt-get clean
577
    sudo apt-get autoremove
578
    sudo rm -rf /tmp/*
579
    sudo rm -rf openvswitch*.tar.gz
580

    
581
    # Remove sensistive files
582
    history -c  # note this won't work if you have multiple bash sessions
583
    rm -f ~/.bash_history  # need to clear in memory and remove on disk
584
    rm -f ~/.ssh/id_rsa* ~/.ssh/known_hosts
585
    sudo rm -f ~/.ssh/authorized_keys*
586

    
587
    # Remove Mininet files
588
    #sudo rm -f /lib/modules/python2.5/site-packages/mininet*
589
    #sudo rm -f /usr/bin/mnexec
590

    
591
    # Clear optional dev script for SSH keychain load on boot
592
    rm -f ~/.bash_profile
593

    
594
    # Clear git changes
595
    git config --global user.name "None"
596
    git config --global user.email "None"
597

    
598
    # Note: you can shrink the .vmdk in vmware using
599
    # vmware-vdiskmanager -k *.vmdk
600
    echo "Zeroing out disk blocks for efficient compaction..."
601
    time sudo dd if=/dev/zero of=/tmp/zero bs=1M
602
    sync ; sleep 1 ; sync ; sudo rm -f /tmp/zero
603

    
604
}
605

    
606
function usage {
607
    printf '\nUsage: %s [-abcdfhkmnprtvwx03]\n\n' $(basename $0) >&2
608

    
609
    printf 'This install script attempts to install useful packages\n' >&2
610
    printf 'for Mininet. It should (hopefully) work on Ubuntu 11.10+\n' >&2
611
    printf 'If you run into trouble, try\n' >&2
612
    printf 'installing one thing at a time, and looking at the \n' >&2
613
    printf 'specific installation function in this script.\n\n' >&2
614

    
615
    printf 'options:\n' >&2
616
    printf -- ' -a: (default) install (A)ll packages - good luck!\n' >&2
617
    printf -- ' -b: install controller (B)enchmark (oflops)\n' >&2
618
    printf -- ' -c: (C)lean up after kernel install\n' >&2
619
    printf -- ' -d: (D)elete some sensitive files from a VM image\n' >&2
620
    printf -- ' -f: install open(F)low\n' >&2
621
    printf -- ' -h: print this (H)elp message\n' >&2
622
    printf -- ' -k: install new (K)ernel\n' >&2
623
    printf -- ' -m: install Open vSwitch kernel (M)odule from source dir\n' >&2
624
    printf -- ' -n: install mini(N)et dependencies + core files\n' >&2
625
    printf -- ' -p: install (P)OX OpenFlow Controller\n' >&2
626
    printf -- ' -r: remove existing Open vSwitch packages\n' >&2
627
    printf -- ' -t: complete o(T)her Mininet VM setup tasks\n' >&2
628
    printf -- ' -v: install open (V)switch\n' >&2
629
    printf -- ' -w: install OpenFlow (w)ireshark dissector\n' >&2
630
    printf -- ' -x: install NO(X) Classic OpenFlow controller\n' >&2
631
    printf -- ' -0: (default) -0[fx] installs OpenFlow 1.0 versions\n' >&2
632
    printf -- ' -3: -3[fx] installs OpenFlow 1.3 versions\n' >&2
633
    printf -- ' -i < directory >: sets the (I)nstallation directory for Mininet dependencies\n' >&2
634
    exit 2
635
}
636

    
637
OF_VERSION=1.0
638

    
639
if [ $# -eq 0 ]
640
then
641
    all
642
else
643
    while getopts 'abcdfhkmnprtvwx03i:' OPTION
644
    do
645
      case $OPTION in
646
      a)    all;;
647
      b)    cbench;;
648
      c)    kernel_clean;;
649
      d)    vm_clean;;
650
      f)    case $OF_VERSION in
651
            1.0) of;;
652
            1.3) of13;;
653
            *)  echo "Invalid OpenFlow version $OF_VERSION";;
654
            esac;;
655
      h)    usage;;
656
      k)    kernel;;
657
      m)    modprobe;;
658
      n)    mn_deps;;
659
      p)    pox;;
660
      r)    remove_ovs;;
661
      t)    vm_other;;
662
      v)    ovs;;
663
      w)    wireshark;;
664
      x)    case $OF_VERSION in
665
            1.0) nox;;
666
            1.3) nox13;;
667
            *)  echo "Invalid OpenFlow version $OF_VERSION";;
668
            esac;;
669
      0)    OF_VERSION=1.0;;
670
      3)    OF_VERSION=1.3;;
671
      i)    mkdir -p $OPTARG; # ensure the directory is created
672
            BUILD_DIR="$( cd -P "$OPTARG" && pwd )"; # get the full path of the directory
673
            echo "Dependency installation directory: $BUILD_DIR";;
674
      ?)    usage;;
675
      esac
676
    done
677
    shift $(($OPTIND - 1))
678
fi