Statistics
| Branch: | Tag: | Revision:

mininet / util / install.sh @ 65c35b65

History | View | Annotate | Download (19.3 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
# Location of CONFIG_NET_NS-enabled kernel(s)
13
KERNEL_LOC=http://www.openflow.org/downloads/mininet
14

    
15
# Attempt to identify Linux release
16

    
17
DIST=Unknown
18
RELEASE=Unknown
19
CODENAME=Unknown
20
ARCH=`uname -m`
21
if [ "$ARCH" = "x86_64" ]; then ARCH="amd64"; fi
22
if [ "$ARCH" = "i686" ]; then ARCH="i386"; fi
23

    
24
test -e /etc/debian_version && DIST="Debian"
25
grep Ubuntu /etc/lsb-release &> /dev/null && DIST="Ubuntu"
26
if [ "$DIST" = "Ubuntu" ] || [ "$DIST" = "Debian" ]; then
27
    install='sudo apt-get -y install'
28
    remove='sudo apt-get -y remove'
29
    pkginst='sudo dpkg -i'
30
    # Prereqs for this script
31
    if ! which lsb_release &> /dev/null; then
32
        $install lsb-release
33
    fi
34
    if ! which bc &> /dev/null; then
35
        $install bc
36
    fi
37
fi
38
if which lsb_release &> /dev/null; then
39
    DIST=`lsb_release -is`
40
    RELEASE=`lsb_release -rs`
41
    CODENAME=`lsb_release -cs`
42
fi
43
echo "Detected Linux distribution: $DIST $RELEASE $CODENAME $ARCH"
44

    
45
# Kernel params
46

    
47
if [ "$DIST" = "Ubuntu" ]; then
48
    if [ "$RELEASE" = "10.04" ]; then
49
        KERNEL_NAME='3.0.0-15-generic'
50
    else
51
        KERNEL_NAME=`uname -r`
52
    fi
53
    KERNEL_HEADERS=linux-headers-${KERNEL_NAME}
54
elif [ "$DIST" = "Debian" ] && [ "$ARCH" = "i386" ] && [ "$CODENAME" = "lenny" ]; then
55
    KERNEL_NAME=2.6.33.1-mininet
56
    KERNEL_HEADERS=linux-headers-${KERNEL_NAME}_${KERNEL_NAME}-10.00.Custom_i386.deb
57
    KERNEL_IMAGE=linux-image-${KERNEL_NAME}_${KERNEL_NAME}-10.00.Custom_i386.deb
58
else
59
    echo "Install.sh currently only supports Ubuntu and Debian Lenny i386."
60
    exit 1
61
fi
62

    
63
# More distribution info
64
DIST_LC=`echo $DIST | tr [A-Z] [a-z]` # as lower case
65

    
66
# Kernel Deb pkg to be removed:
67
KERNEL_IMAGE_OLD=linux-image-2.6.26-33-generic
68

    
69
DRIVERS_DIR=/lib/modules/${KERNEL_NAME}/kernel/drivers/net
70

    
71
OVS_RELEASE=1.4.0
72
OVS_PACKAGE_LOC=https://github.com/downloads/mininet/mininet
73
OVS_BUILDSUFFIX=-ignore # was -2
74
OVS_PACKAGE_NAME=ovs-$OVS_RELEASE-core-$DIST_LC-$RELEASE-$ARCH$OVS_BUILDSUFFIX.tar
75
OVS_SRC=~/openvswitch
76
OVS_TAG=v$OVS_RELEASE
77
OVS_BUILD=$OVS_SRC/build-$KERNEL_NAME
78
OVS_KMODS=($OVS_BUILD/datapath/linux/{openvswitch_mod.ko,brcompat_mod.ko})
79

    
80
function kernel {
81
    echo "Install Mininet-compatible kernel if necessary"
82
    sudo apt-get update
83
    if [ "$DIST" = "Ubuntu" ] &&  [ "$RELEASE" = "10.04" ]; then
84
        $install linux-image-$KERNEL_NAME
85
    elif [ "$DIST" = "Debian" ]; then
86
        # The easy approach: download pre-built linux-image and linux-headers packages:
87
        wget -c $KERNEL_LOC/$KERNEL_HEADERS
88
        wget -c $KERNEL_LOC/$KERNEL_IMAGE
89

    
90
        # Install custom linux headers and image:
91
        $pkginst $KERNEL_IMAGE $KERNEL_HEADERS
92

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

    
101
        # Ensure /boot/grub/menu.lst boots with initrd image:
102
        sudo update-grub
103

    
104
        # The default should be the new kernel. Otherwise, you may need to modify
105
        # /boot/grub/menu.lst to set the default to the entry corresponding to the
106
        # kernel you just installed.
107
    fi
108
}
109

    
110
function kernel_clean {
111
    echo "Cleaning kernel..."
112

    
113
    # To save disk space, remove previous kernel
114
    if ! $remove $KERNEL_IMAGE_OLD; then
115
        echo $KERNEL_IMAGE_OLD not installed.
116
    fi
117

    
118
    # Also remove downloaded packages:
119
    rm -f ~/linux-headers-* ~/linux-image-*
120
}
121

    
122
# Install Mininet deps
123
function mn_deps {
124
    echo "Installing Mininet dependencies"
125
    $install gcc make socat psmisc xterm ssh iperf iproute telnet \
126
        python-setuptools cgroup-bin ethtool help2man \
127
        pyflakes pylint pep8
128

    
129
    # Add sysctl parameters as noted in the INSTALL file to increase kernel
130
    # limits to support larger setups:
131
    if ! grep Mininet /etc/sysctl.conf; then
132
        echo "Adding Mininet sysctl settings"
133
        sudo su -c "cat $HOME/mininet/util/sysctl_addon >> /etc/sysctl.conf"
134
    fi
135
    # Load new sysctl settings:
136
    sudo sysctl -p
137

    
138
    echo "Installing Mininet core"
139
    pushd ~/mininet
140
    sudo make install
141
    popd
142
}
143

    
144
# The following will cause a full OF install, covering:
145
# -user switch
146
# The instructions below are an abbreviated version from
147
# http://www.openflowswitch.org/wk/index.php/Debian_Install
148
# ... modified to use Debian Lenny rather than unstable.
149
function of {
150
    echo "Installing OpenFlow reference implementation..."
151
    cd ~/
152
    $install git-core autoconf automake autotools-dev pkg-config \
153
		make gcc libtool libc6-dev
154
    git clone git://openflowswitch.org/openflow.git
155
    cd ~/openflow
156

    
157
    # Patch controller to handle more than 16 switches
158
    patch -p1 < ~/mininet/util/openflow-patches/controller.patch
159

    
160
    # Resume the install:
161
    ./boot.sh
162
    ./configure
163
    make
164
    sudo make install
165
    cd ~
166
}
167

    
168
function of13 {
169
    echo "Installing OpenFlow 1.3 soft switch implementation..."
170
    cd ~/
171
    $install  git-core autoconf automake autotools-dev pkg-config \
172
        make gcc g++ libtool libc6-dev cmake libpcap-dev libxerces-c2-dev  \
173
        unzip libpcre3-dev flex bison libboost-dev
174

    
175
    if [ ! -d "ofsoftswitch13" ]; then
176
         git clone https://github.com/CPqD/ofsoftswitch13.git
177
    fi
178

    
179
    # Install netbee
180
    wget -nc http://www.nbee.org/download/nbeesrc-12-05-16.zip
181
    unzip nbeesrc-12-05-16.zip
182
    cd ~/nbeesrc/src
183
    cmake .
184
    make
185
    cd ~/
186
    sudo cp nbeesrc/bin/libn*.so /usr/local/lib
187
    sudo ldconfig
188
    sudo cp -R nbeesrc/include/ /usr/
189

    
190
    # Resume the install:
191
    cd ~/ofsoftswitch13
192
    ./boot.sh
193
    ./configure
194
    make
195
    sudo make install
196
    cd ~
197
}
198

    
199
function wireshark {
200
    echo "Installing Wireshark dissector..."
201

    
202
    sudo apt-get install -y wireshark tshark libgtk2.0-dev
203

    
204
    if [ "$DIST" = "Ubuntu" ] && [ "$RELEASE" != "10.04" ]; then
205
        # Install newer version
206
        sudo apt-get install -y scons mercurial libglib2.0-dev
207
        sudo apt-get install -y libwiretap-dev libwireshark-dev
208
        cd ~
209
        hg clone https://bitbucket.org/barnstorm/of-dissector
210
        cd of-dissector/src
211
        export WIRESHARK=/usr/include/wireshark
212
        scons
213
        # libwireshark0/ on 11.04; libwireshark1/ on later
214
        WSDIR=`ls -d /usr/lib/wireshark/libwireshark* | head -1`
215
        WSPLUGDIR=$WSDIR/plugins/
216
        sudo cp openflow.so $WSPLUGDIR
217
        echo "Copied openflow plugin to $WSPLUGDIR"
218
    else
219
        # Install older version from reference source
220
        cd ~/openflow/utilities/wireshark_dissectors/openflow
221
        make
222
        sudo make install
223
    fi
224

    
225
    # Copy coloring rules: OF is white-on-blue:
226
    mkdir -p ~/.wireshark
227
    cp ~/mininet/util/colorfilters ~/.wireshark
228
}
229

    
230

    
231
# Install Open vSwitch
232
# Instructions derived from OVS INSTALL, INSTALL.OpenFlow and README files.
233

    
234
function ovs {
235
    echo "Installing Open vSwitch..."
236

    
237
    # Required for module build/dkms install
238
    $install $KERNEL_HEADERS
239

    
240
    ovspresent=0
241

    
242
    # First see if we have packages
243
    # XXX wget -c seems to fail from github/amazon s3
244
    cd /tmp
245
    if wget $OVS_PACKAGE_LOC/$OVS_PACKAGE_NAME 2> /dev/null; then
246
	$install patch dkms fakeroot python-argparse
247
        tar xf $OVS_PACKAGE_NAME
248
        orig=`tar tf $OVS_PACKAGE_NAME`
249
        # Now install packages in reasonable dependency order
250
        order='dkms common pki openvswitch-switch brcompat controller'
251
        pkgs=""
252
        for p in $order; do
253
            pkg=`echo "$orig" | grep $p`
254
	    # Annoyingly, things seem to be missing without this flag
255
            $pkginst --force-confmiss $pkg
256
        done
257
        ovspresent=1
258
    fi
259

    
260
    # Otherwise try distribution's OVS packages
261
    if [ "$DIST" = "Ubuntu" ] && [ `expr $RELEASE '>=' 11.10` = 1 ]; then
262
        if ! dpkg --get-selections | grep openvswitch-datapath; then
263
            # If you've already installed a datapath, assume you
264
            # know what you're doing and don't need dkms datapath.
265
            # Otherwise, install it.
266
            $install openvswitch-datapath-dkms
267
        fi
268
	if $install openvswitch-switch openvswitch-controller; then
269
            echo "Ignoring error installing openvswitch-controller"
270
        fi
271
        ovspresent=1
272
    fi
273

    
274
    # Switch can run on its own, but
275
    # Mininet should control the controller
276
    if [ -e /etc/init.d/openvswitch-controller ]; then
277
        if sudo service openvswitch-controller stop; then
278
            echo "Stopped running controller"
279
        fi
280
        sudo update-rc.d openvswitch-controller disable
281
    fi
282

    
283
    if [ $ovspresent = 1 ]; then
284
        echo "Done (hopefully) installing packages"
285
        cd ~
286
        return
287
    fi
288

    
289
    # Otherwise attempt to install from source
290

    
291
    $install pkg-config gcc make python-dev libssl-dev libtool
292

    
293
    if [ "$DIST" = "Debian" ]; then
294
        if [ "$CODENAME" = "lenny" ]; then
295
            $install git-core
296
            # Install Autoconf 2.63+ backport from Debian Backports repo:
297
            # Instructions from http://backports.org/dokuwiki/doku.php?id=instructions
298
            sudo su -c "echo 'deb http://www.backports.org/debian lenny-backports main contrib non-free' >> /etc/apt/sources.list"
299
            sudo apt-get update
300
            sudo apt-get -y --force-yes install debian-backports-keyring
301
            sudo apt-get -y --force-yes -t lenny-backports install autoconf
302
        fi
303
    else
304
        $install git
305
    fi
306

    
307
    # Install OVS from release
308
    cd ~/
309
    git clone git://openvswitch.org/openvswitch $OVS_SRC
310
    cd $OVS_SRC
311
    git checkout $OVS_TAG
312
    ./boot.sh
313
    BUILDDIR=/lib/modules/${KERNEL_NAME}/build
314
    if [ ! -e $BUILDDIR ]; then
315
        echo "Creating build sdirectory $BUILDDIR"
316
        sudo mkdir -p $BUILDDIR
317
    fi
318
    opts="--with-linux=$BUILDDIR"
319
    mkdir -p $OVS_BUILD
320
    cd $OVS_BUILD
321
    ../configure $opts
322
    make
323
    sudo make install
324

    
325
    modprobe
326
}
327

    
328
function remove_ovs {
329
    pkgs=`dpkg --get-selections | grep openvswitch | awk '{ print $1;}'`
330
    echo "Removing existing Open vSwitch packages:"
331
    echo $pkgs
332
    if ! $remove $pkgs; then
333
        echo "Not all packages removed correctly"
334
    fi
335
    # For some reason this doesn't happen
336
    if scripts=`ls /etc/init.d/*openvswitch* 2>/dev/null`; then
337
        echo $scripts
338
        for s in $scripts; do
339
            s=$(basename $s)
340
            echo SCRIPT $s
341
            sudo service $s stop
342
            sudo rm -f /etc/init.d/$s
343
            sudo update-rc.d -f $s remove
344
        done
345
    fi
346
    echo "Done removing OVS"
347
}
348

    
349
# Install NOX with tutorial files
350
function nox {
351
    echo "Installing NOX w/tutorial files..."
352

    
353
    # Install NOX deps:
354
    $install autoconf automake g++ libtool python python-twisted \
355
		swig libssl-dev make
356
    if [ "$DIST" = "Debian" ]; then
357
        $install libboost1.35-dev
358
    elif [ "$DIST" = "Ubuntu" ]; then
359
        $install python-dev libboost-dev
360
        $install libboost-filesystem-dev
361
        $install libboost-test-dev
362
    fi
363
    # Install NOX optional deps:
364
    $install libsqlite3-dev python-simplejson
365

    
366
    # Fetch NOX destiny
367
    cd ~/
368
    git clone https://github.com/noxrepo/nox-classic.git noxcore
369
    cd noxcore
370
    if ! git checkout -b destiny remotes/origin/destiny ; then
371
        echo "Did not check out a new destiny branch - assuming current branch is destiny"
372
    fi
373

    
374
    # Apply patches
375
    git checkout -b tutorial-destiny
376
    git am ~/mininet/util/nox-patches/*tutorial-port-nox-destiny*.patch
377
    if [ "$DIST" = "Ubuntu" ] && [ `expr $RELEASE '>=' 12.04` = 1 ]; then
378
        git am ~/mininet/util/nox-patches/*nox-ubuntu12-hacks.patch
379
    fi
380

    
381
    # Build
382
    ./boot.sh
383
    mkdir build
384
    cd build
385
    ../configure
386
    make -j3
387
    #make check
388

    
389
    # Add NOX_CORE_DIR env var:
390
    sed -i -e 's|# for examples$|&\nexport NOX_CORE_DIR=~/noxcore/build/src|' ~/.bashrc
391

    
392
    # To verify this install:
393
    #cd ~/noxcore/build/src
394
    #./nox_core -v -i ptcp:
395
}
396

    
397
# Install NOX Classic/Zaku for OpenFlow 1.3
398
function nox13 {
399
    echo "Installing NOX w/tutorial files..."
400

    
401
    # Install NOX deps:
402
    $install autoconf automake g++ libtool python python-twisted \
403
        swig libssl-dev make
404
    if [ "$DIST" = "Debian" ]; then
405
        $install libboost1.35-dev
406
    elif [ "$DIST" = "Ubuntu" ]; then
407
        $install python-dev libboost-dev
408
        $install libboost-filesystem-dev
409
        $install libboost-test-dev
410
    fi
411

    
412
    # Fetch NOX destiny
413
    cd ~/
414
    git clone https://github.com/CPqD/nox13oflib.git
415
    cd nox13oflib
416

    
417
    # Build
418
    ./boot.sh
419
    mkdir build
420
    cd build
421
    ../configure
422
    make -j3
423
    #make check
424

    
425
    # To verify this install:
426
    #cd ~/nox13oflib/build/src
427
    #./nox_core -v -i ptcp:
428
}
429

    
430

    
431
# "Install" POX
432
function pox {
433
    echo "Installing POX into $HOME/pox..."
434
    cd ~
435
    git clone https://github.com/noxrepo/pox.git
436
}
437

    
438
# Install OFtest
439
function oftest {
440
    echo "Installing oftest..."
441

    
442
    # Install deps:
443
    $install tcpdump python-scapy
444

    
445
    # Install oftest:
446
    cd ~/
447
    git clone git://github.com/floodlight/oftest
448
}
449

    
450
# Install cbench
451
function cbench {
452
    echo "Installing cbench..."
453

    
454
    $install libsnmp-dev libpcap-dev libconfig-dev
455
    cd ~/
456
    git clone git://openflow.org/oflops.git
457
    cd oflops
458
    sh boot.sh || true # possible error in autoreconf, so run twice
459
    sh boot.sh
460
    ./configure --with-openflow-src-dir=$HOME/openflow
461
    make
462
    sudo make install || true # make install fails; force past this
463
}
464

    
465
function other {
466
    echo "Doing other Mininet VM setup tasks..."
467

    
468
    # Remove avahi-daemon, which may cause unwanted discovery packets to be
469
    # sent during tests, near link status changes:
470
    echo "Removing avahi-daemon"
471
    $remove avahi-daemon
472

    
473
    # was: Disable IPv6.  Add to /etc/modprobe.d/blacklist:
474
    #echo "Attempting to disable IPv6"
475
    #if [ "$DIST" = "Ubuntu" ]; then
476
    #    BLACKLIST=/etc/modprobe.d/blacklist.conf
477
    #else
478
    #    BLACKLIST=/etc/modprobe.d/blacklist
479
    #fi
480
    #sudo sh -c "echo 'blacklist net-pf-10\nblacklist ipv6' >> $BLACKLIST"
481

    
482
    # Disable IPv6
483
    if ! grep 'disable IPv6' /etc/sysctl.conf; then
484
        echo 'Disabling IPv6'
485
        echo '
486
# Mininet: disable IPv6
487
net.ipv6.conf.all.disable_ipv6 = 1
488
net.ipv6.conf.default.disable_ipv6 = 1
489
net.ipv6.conf.lo.disable_ipv6 = 1' | sudo tee -a /etc/sysctl.conf > /dev/null
490
    fi
491
    # Disabling IPv6 breaks X11 forwarding via ssh
492
    line='AddressFamily inet'
493
    file='/etc/ssh/sshd_config'
494
    echo "Adding $line to $file"
495
    if ! grep "$line" $file > /dev/null; then
496
        echo "$line" | sudo tee -a $file > /dev/null
497
    fi
498

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

    
502
    # Install tcpdump, cmd-line packet dump tool.  Also install gitk,
503
    # a graphical git history viewer.
504
    $install tcpdump gitk
505

    
506
    # Install common text editors
507
    $install vim nano emacs
508

    
509
    # Install NTP
510
    $install ntp
511

    
512
    # Set git to colorize everything.
513
    git config --global color.diff auto
514
    git config --global color.status auto
515
    git config --global color.branch auto
516

    
517
    # Reduce boot screen opt-out delay. Modify timeout in /boot/grub/menu.lst to 1:
518
    if [ "$DIST" = "Debian" ]; then
519
        sudo sed -i -e 's/^timeout.*$/timeout         1/' /boot/grub/menu.lst
520
    fi
521

    
522
    # Clean unneeded debs:
523
    rm -f ~/linux-headers-* ~/linux-image-*
524
}
525

    
526
# Script to copy built OVS kernel module to where modprobe will
527
# find them automatically.  Removes the need to keep an environment variable
528
# for insmod usage, and works nicely with multiple kernel versions.
529
#
530
# The downside is that after each recompilation of OVS you'll need to
531
# re-run this script.  If you're using only one kernel version, then it may be
532
# a good idea to use a symbolic link in place of the copy below.
533
function modprobe {
534
    echo "Setting up modprobe for OVS kmod..."
535

    
536
    sudo cp $OVS_KMODS $DRIVERS_DIR
537
    sudo depmod -a ${KERNEL_NAME}
538
}
539

    
540
function all {
541
    echo "Running all commands..."
542
    kernel
543
    mn_deps
544
    of
545
    wireshark
546
    ovs
547
    # NOX-classic is deprecated, but you can install it manually if desired.
548
    # nox
549
    pox
550
    oftest
551
    cbench
552
    other
553
    echo "Please reboot, then run ./mininet/util/install.sh -c to remove unneeded packages."
554
    echo "Enjoy Mininet!"
555
}
556

    
557
# Restore disk space and remove sensitive files before shipping a VM.
558
function vm_clean {
559
    echo "Cleaning VM..."
560
    sudo apt-get clean
561
    sudo rm -rf /tmp/*
562
    sudo rm -rf openvswitch*.tar.gz
563

    
564
    # Remove sensistive files
565
    history -c  # note this won't work if you have multiple bash sessions
566
    rm -f ~/.bash_history  # need to clear in memory and remove on disk
567
    rm -f ~/.ssh/id_rsa* ~/.ssh/known_hosts
568
    sudo rm -f ~/.ssh/authorized_keys*
569

    
570
    # Remove Mininet files
571
    #sudo rm -f /lib/modules/python2.5/site-packages/mininet*
572
    #sudo rm -f /usr/bin/mnexec
573

    
574
    # Clear optional dev script for SSH keychain load on boot
575
    rm -f ~/.bash_profile
576

    
577
    # Clear git changes
578
    git config --global user.name "None"
579
    git config --global user.email "None"
580

    
581
    # Remove mininet install script
582
    rm -f install-mininet.sh
583
}
584

    
585
function usage {
586
    printf '\nUsage: %s [-abcdfhkmnprtvwx03]\n\n' $(basename $0) >&2
587

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

    
594
    printf 'options:\n' >&2
595
    printf -- ' -a: (default) install (A)ll packages - good luck!\n' >&2
596
    printf -- ' -b: install controller (B)enchmark (oflops)\n' >&2
597
    printf -- ' -c: (C)lean up after kernel install\n' >&2
598
    printf -- ' -d: (D)elete some sensitive files from a VM image\n' >&2
599
    printf -- ' -f: install open(F)low\n' >&2
600
    printf -- ' -h: print this (H)elp message\n' >&2
601
    printf -- ' -k: install new (K)ernel\n' >&2
602
    printf -- ' -m: install Open vSwitch kernel (M)odule from source dir\n' >&2
603
    printf -- ' -n: install mini(N)et dependencies + core files\n' >&2
604
    printf -- ' -p: install (P)OX OpenFlow Controller\n' >&2
605
    printf -- ' -r: remove existing Open vSwitch packages\n' >&2
606
    printf -- ' -t: install o(T)her stuff\n' >&2
607
    printf -- ' -v: install open (V)switch\n' >&2
608
    printf -- ' -w: install OpenFlow (w)ireshark dissector\n' >&2
609
    printf -- ' -x: install NO(X) Classic OpenFlow controller\n' >&2
610
    printf -- ' -0: (default) -0[fx] installs OpenFlow 1.0 versions\n' >&2
611
    printf -- ' -3: -3[fx] installs OpenFlow 1.3 versions\n' >&2
612
    exit 2
613
}
614

    
615
OF_VERSION=1.0
616

    
617
if [ $# -eq 0 ]
618
then
619
    all
620
else
621
    while getopts 'abcdfhkmnprtvwx03' OPTION
622
    do
623
      case $OPTION in
624
      a)    all;;
625
      b)    cbench;;
626
      c)    kernel_clean;;
627
      d)    vm_clean;;
628
      f)    case $OF_VERSION in
629
            1.0) of;;
630
            1.3) of13;;
631
            *)  echo "Invalid OpenFlow version $OF_VERSION";;
632
            esac;;
633
      h)    usage;;
634
      k)    kernel;;
635
      m)    modprobe;;
636
      n)    mn_deps;;
637
      p)    pox;;
638
      r)    remove_ovs;;
639
      t)    other;;
640
      v)    ovs;;
641
      w)    wireshark;;
642
      x)    case $OF_VERSION in
643
            1.0) nox;;
644
            1.3) nox13;;
645
            *)  echo "Invalid OpenFlow version $OF_VERSION";;
646
            esac;;
647
      0)    OF_VERSION=1.0;;
648
      3)    OF_VERSION=1.3;;
649
      ?)    usage;;
650
      esac
651
    done
652
    shift $(($OPTIND - 1))
653
fi