carlosmscabral | f40ecd1 | 2013-02-01 18:15:58 -0200 | [diff] [blame] | 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 screen psmisc xterm ssh iperf iproute telnet \ |
| 126 | python-setuptools python-networkx cgroup-bin ethtool help2man \ |
| 127 | pyflakes pylint pep8 |
| 128 | |
| 129 | if [ "$DIST" = "Ubuntu" ] && [ "$RELEASE" = "10.04" ]; then |
| 130 | echo "Upgrading networkx to avoid deprecation warning" |
| 131 | sudo easy_install --upgrade networkx |
| 132 | fi |
| 133 | |
| 134 | # Add sysctl parameters as noted in the INSTALL file to increase kernel |
| 135 | # limits to support larger setups: |
carlosmscabral | 4cf72ea | 2013-02-04 12:33:50 -0200 | [diff] [blame^] | 136 | sudo su -c "cat $HOME/mn-ccnx/util/sysctl_addon >> /etc/sysctl.conf" |
carlosmscabral | f40ecd1 | 2013-02-01 18:15:58 -0200 | [diff] [blame] | 137 | |
| 138 | # Load new sysctl settings: |
| 139 | sudo sysctl -p |
| 140 | |
carlosmscabral | 4cf72ea | 2013-02-04 12:33:50 -0200 | [diff] [blame^] | 141 | echo "Installing Mininet/Mini-CCNx core" |
| 142 | pushd ~/mn-ccnx |
carlosmscabral | f40ecd1 | 2013-02-01 18:15:58 -0200 | [diff] [blame] | 143 | sudo make install |
| 144 | popd |
| 145 | } |
| 146 | |
| 147 | # The following will cause a full OF install, covering: |
| 148 | # -user switch |
| 149 | # The instructions below are an abbreviated version from |
| 150 | # http://www.openflowswitch.org/wk/index.php/Debian_Install |
| 151 | # ... modified to use Debian Lenny rather than unstable. |
| 152 | function of { |
| 153 | echo "Installing OpenFlow reference implementation..." |
| 154 | cd ~/ |
| 155 | $install git-core autoconf automake autotools-dev pkg-config \ |
| 156 | make gcc libtool libc6-dev |
| 157 | git clone git://openflowswitch.org/openflow.git |
| 158 | cd ~/openflow |
| 159 | |
| 160 | # Patch controller to handle more than 16 switches |
| 161 | patch -p1 < ~/mininet/util/openflow-patches/controller.patch |
| 162 | |
| 163 | # Resume the install: |
| 164 | ./boot.sh |
| 165 | ./configure |
| 166 | make |
| 167 | sudo make install |
| 168 | |
| 169 | # Remove avahi-daemon, which may cause unwanted discovery packets to be |
| 170 | # sent during tests, near link status changes: |
| 171 | $remove avahi-daemon |
| 172 | |
| 173 | # Disable IPv6. Add to /etc/modprobe.d/blacklist: |
| 174 | if [ "$DIST" = "Ubuntu" ]; then |
| 175 | BLACKLIST=/etc/modprobe.d/blacklist.conf |
| 176 | else |
| 177 | BLACKLIST=/etc/modprobe.d/blacklist |
| 178 | fi |
| 179 | sudo sh -c "echo 'blacklist net-pf-10\nblacklist ipv6' >> $BLACKLIST" |
| 180 | cd ~ |
| 181 | } |
| 182 | |
| 183 | function wireshark { |
| 184 | echo "Installing Wireshark dissector..." |
| 185 | |
| 186 | sudo apt-get install -y wireshark libgtk2.0-dev |
| 187 | |
| 188 | if [ "$DIST" = "Ubuntu" ] && [ "$RELEASE" != "10.04" ]; then |
| 189 | # Install newer version |
| 190 | sudo apt-get install -y scons mercurial libglib2.0-dev |
| 191 | sudo apt-get install -y libwiretap-dev libwireshark-dev |
| 192 | cd ~ |
| 193 | hg clone https://bitbucket.org/barnstorm/of-dissector |
| 194 | cd of-dissector/src |
| 195 | export WIRESHARK=/usr/include/wireshark |
| 196 | scons |
| 197 | # libwireshark0/ on 11.04; libwireshark1/ on later |
| 198 | WSDIR=`ls -d /usr/lib/wireshark/libwireshark* | head -1` |
| 199 | WSPLUGDIR=$WSDIR/plugins/ |
| 200 | sudo cp openflow.so $WSPLUGDIR |
| 201 | echo "Copied openflow plugin to $WSPLUGDIR" |
| 202 | else |
| 203 | # Install older version from reference source |
| 204 | cd ~/openflow/utilities/wireshark_dissectors/openflow |
| 205 | make |
| 206 | sudo make install |
| 207 | fi |
| 208 | |
| 209 | # Copy coloring rules: OF is white-on-blue: |
| 210 | mkdir -p ~/.wireshark |
carlosmscabral | 4cf72ea | 2013-02-04 12:33:50 -0200 | [diff] [blame^] | 211 | cp ~/mn-ccnx/util/colorfilters ~/.wireshark |
carlosmscabral | f40ecd1 | 2013-02-01 18:15:58 -0200 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | |
| 215 | # Install Open vSwitch |
| 216 | # Instructions derived from OVS INSTALL, INSTALL.OpenFlow and README files. |
| 217 | |
| 218 | function ovs { |
| 219 | echo "Installing Open vSwitch..." |
| 220 | |
| 221 | # Required for module build/dkms install |
| 222 | $install $KERNEL_HEADERS |
| 223 | |
| 224 | ovspresent=0 |
| 225 | |
| 226 | # First see if we have packages |
| 227 | # XXX wget -c seems to fail from github/amazon s3 |
| 228 | cd /tmp |
| 229 | if wget $OVS_PACKAGE_LOC/$OVS_PACKAGE_NAME 2> /dev/null; then |
| 230 | $install patch dkms fakeroot python-argparse |
| 231 | tar xf $OVS_PACKAGE_NAME |
| 232 | orig=`tar tf $OVS_PACKAGE_NAME` |
| 233 | # Now install packages in reasonable dependency order |
| 234 | order='dkms common pki openvswitch-switch brcompat controller' |
| 235 | pkgs="" |
| 236 | for p in $order; do |
| 237 | pkg=`echo "$orig" | grep $p` |
| 238 | # Annoyingly, things seem to be missing without this flag |
| 239 | $pkginst --force-confmiss $pkg |
| 240 | done |
| 241 | ovspresent=1 |
| 242 | fi |
| 243 | |
| 244 | # Otherwise try distribution's OVS packages |
| 245 | if [ "$DIST" = "Ubuntu" ] && [ `expr $RELEASE '>=' 11.10` = 1 ]; then |
| 246 | if ! dpkg --get-selections | grep openvswitch-datapath; then |
| 247 | # If you've already installed a datapath, assume you |
| 248 | # know what you're doing and don't need dkms datapath. |
| 249 | # Otherwise, install it. |
| 250 | $install openvswitch-datapath-dkms |
| 251 | fi |
| 252 | if $install openvswitch-switch openvswitch-controller; then |
| 253 | echo "Ignoring error installing openvswitch-controller" |
| 254 | fi |
| 255 | ovspresent=1 |
| 256 | fi |
| 257 | |
| 258 | # Switch can run on its own, but |
| 259 | # Mininet should control the controller |
| 260 | if [ -e /etc/init.d/openvswitch-controller ]; then |
| 261 | if sudo service openvswitch-controller stop; then |
| 262 | echo "Stopped running controller" |
| 263 | fi |
| 264 | sudo update-rc.d openvswitch-controller disable |
| 265 | fi |
| 266 | |
| 267 | if [ $ovspresent = 1 ]; then |
| 268 | echo "Done (hopefully) installing packages" |
| 269 | cd ~ |
| 270 | return |
| 271 | fi |
| 272 | |
| 273 | # Otherwise attempt to install from source |
| 274 | |
| 275 | $install pkg-config gcc make python-dev libssl-dev libtool |
| 276 | |
| 277 | if [ "$DIST" = "Debian" ]; then |
| 278 | if [ "$CODENAME" = "lenny" ]; then |
| 279 | $install git-core |
| 280 | # Install Autoconf 2.63+ backport from Debian Backports repo: |
| 281 | # Instructions from http://backports.org/dokuwiki/doku.php?id=instructions |
| 282 | sudo su -c "echo 'deb http://www.backports.org/debian lenny-backports main contrib non-free' >> /etc/apt/sources.list" |
| 283 | sudo apt-get update |
| 284 | sudo apt-get -y --force-yes install debian-backports-keyring |
| 285 | sudo apt-get -y --force-yes -t lenny-backports install autoconf |
| 286 | fi |
| 287 | else |
| 288 | $install git |
| 289 | fi |
| 290 | |
| 291 | # Install OVS from release |
| 292 | cd ~/ |
| 293 | git clone git://openvswitch.org/openvswitch $OVS_SRC |
| 294 | cd $OVS_SRC |
| 295 | git checkout $OVS_TAG |
| 296 | ./boot.sh |
| 297 | BUILDDIR=/lib/modules/${KERNEL_NAME}/build |
| 298 | if [ ! -e $BUILDDIR ]; then |
| 299 | echo "Creating build sdirectory $BUILDDIR" |
| 300 | sudo mkdir -p $BUILDDIR |
| 301 | fi |
| 302 | opts="--with-linux=$BUILDDIR" |
| 303 | mkdir -p $OVS_BUILD |
| 304 | cd $OVS_BUILD |
| 305 | ../configure $opts |
| 306 | make |
| 307 | sudo make install |
| 308 | |
| 309 | modprobe |
| 310 | } |
| 311 | |
| 312 | function remove_ovs { |
| 313 | pkgs=`dpkg --get-selections | grep openvswitch | awk '{ print $1;}'` |
| 314 | echo "Removing existing Open vSwitch packages:" |
| 315 | echo $pkgs |
| 316 | if ! $remove $pkgs; then |
| 317 | echo "Not all packages removed correctly" |
| 318 | fi |
| 319 | # For some reason this doesn't happen |
| 320 | if scripts=`ls /etc/init.d/*openvswitch* 2>/dev/null`; then |
| 321 | echo $scripts |
| 322 | for s in $scripts; do |
| 323 | s=$(basename $s) |
| 324 | echo SCRIPT $s |
| 325 | sudo service $s stop |
| 326 | sudo rm -f /etc/init.d/$s |
| 327 | sudo update-rc.d -f $s remove |
| 328 | done |
| 329 | fi |
| 330 | echo "Done removing OVS" |
| 331 | } |
| 332 | |
| 333 | # Install NOX with tutorial files |
| 334 | function nox { |
| 335 | echo "Installing NOX w/tutorial files..." |
| 336 | |
| 337 | # Install NOX deps: |
| 338 | $install autoconf automake g++ libtool python python-twisted \ |
| 339 | swig libssl-dev make |
| 340 | if [ "$DIST" = "Debian" ]; then |
| 341 | $install libboost1.35-dev |
| 342 | elif [ "$DIST" = "Ubuntu" ]; then |
| 343 | $install python-dev libboost-dev |
| 344 | $install libboost-filesystem-dev |
| 345 | $install libboost-test-dev |
| 346 | fi |
| 347 | # Install NOX optional deps: |
| 348 | $install libsqlite3-dev python-simplejson |
| 349 | |
| 350 | # Fetch NOX destiny |
| 351 | cd ~/ |
| 352 | git clone https://github.com/noxrepo/nox-classic.git noxcore |
| 353 | cd noxcore |
| 354 | if ! git checkout -b destiny remotes/origin/destiny ; then |
| 355 | echo "Did not check out a new destiny branch - assuming current branch is destiny" |
| 356 | fi |
| 357 | |
| 358 | # Apply patches |
| 359 | git checkout -b tutorial-destiny |
carlosmscabral | 4cf72ea | 2013-02-04 12:33:50 -0200 | [diff] [blame^] | 360 | git am ~/mn-ccnx/util/nox-patches/*tutorial-port-nox-destiny*.patch |
carlosmscabral | f40ecd1 | 2013-02-01 18:15:58 -0200 | [diff] [blame] | 361 | if [ "$DIST" = "Ubuntu" ] && [ `expr $RELEASE '>=' 12.04` = 1 ]; then |
carlosmscabral | 4cf72ea | 2013-02-04 12:33:50 -0200 | [diff] [blame^] | 362 | git am ~/mn-ccnx/util/nox-patches/*nox-ubuntu12-hacks.patch |
carlosmscabral | f40ecd1 | 2013-02-01 18:15:58 -0200 | [diff] [blame] | 363 | fi |
| 364 | |
| 365 | # Build |
| 366 | ./boot.sh |
| 367 | mkdir build |
| 368 | cd build |
| 369 | ../configure |
| 370 | make -j3 |
| 371 | #make check |
| 372 | |
| 373 | # Add NOX_CORE_DIR env var: |
| 374 | sed -i -e 's|# for examples$|&\nexport NOX_CORE_DIR=~/noxcore/build/src|' ~/.bashrc |
| 375 | |
| 376 | # To verify this install: |
| 377 | #cd ~/noxcore/build/src |
| 378 | #./nox_core -v -i ptcp: |
| 379 | } |
| 380 | |
| 381 | # "Install" POX |
| 382 | function pox { |
| 383 | echo "Installing POX into $HOME/pox..." |
| 384 | cd ~ |
| 385 | git clone https://github.com/noxrepo/pox.git |
| 386 | } |
| 387 | |
| 388 | # Install OFtest |
| 389 | function oftest { |
| 390 | echo "Installing oftest..." |
| 391 | |
| 392 | # Install deps: |
| 393 | $install tcpdump python-scapy |
| 394 | |
| 395 | # Install oftest: |
| 396 | cd ~/ |
| 397 | git clone git://github.com/floodlight/oftest |
| 398 | cd oftest |
| 399 | cd tools/munger |
| 400 | sudo make install |
| 401 | } |
| 402 | |
| 403 | # Install cbench |
| 404 | function cbench { |
| 405 | echo "Installing cbench..." |
| 406 | |
| 407 | $install libsnmp-dev libpcap-dev libconfig-dev |
| 408 | cd ~/ |
| 409 | git clone git://openflow.org/oflops.git |
| 410 | cd oflops |
| 411 | sh boot.sh || true # possible error in autoreconf, so run twice |
| 412 | sh boot.sh |
| 413 | ./configure --with-openflow-src-dir=$HOME/openflow |
| 414 | make |
| 415 | sudo make install || true # make install fails; force past this |
| 416 | } |
| 417 | |
| 418 | function other { |
| 419 | echo "Doing other setup tasks..." |
| 420 | |
| 421 | # Enable command auto completion using sudo; modify ~/.bashrc: |
| 422 | sed -i -e 's|# for examples$|&\ncomplete -cf sudo|' ~/.bashrc |
| 423 | |
| 424 | # Install tcpdump and tshark, cmd-line packet dump tools. Also install gitk, |
| 425 | # a graphical git history viewer. |
| 426 | $install tcpdump tshark gitk |
| 427 | |
| 428 | # Install common text editors |
| 429 | $install vim nano emacs |
| 430 | |
| 431 | # Install NTP |
| 432 | $install ntp |
| 433 | |
| 434 | # Set git to colorize everything. |
| 435 | git config --global color.diff auto |
| 436 | git config --global color.status auto |
| 437 | git config --global color.branch auto |
| 438 | |
| 439 | # Reduce boot screen opt-out delay. Modify timeout in /boot/grub/menu.lst to 1: |
| 440 | if [ "$DIST" = "Debian" ]; then |
| 441 | sudo sed -i -e 's/^timeout.*$/timeout 1/' /boot/grub/menu.lst |
| 442 | fi |
| 443 | |
| 444 | # Clean unneeded debs: |
| 445 | rm -f ~/linux-headers-* ~/linux-image-* |
| 446 | } |
| 447 | |
| 448 | # Script to copy built OVS kernel module to where modprobe will |
| 449 | # find them automatically. Removes the need to keep an environment variable |
| 450 | # for insmod usage, and works nicely with multiple kernel versions. |
| 451 | # |
| 452 | # The downside is that after each recompilation of OVS you'll need to |
| 453 | # re-run this script. If you're using only one kernel version, then it may be |
| 454 | # a good idea to use a symbolic link in place of the copy below. |
| 455 | function modprobe { |
| 456 | echo "Setting up modprobe for OVS kmod..." |
| 457 | |
| 458 | sudo cp $OVS_KMODS $DRIVERS_DIR |
| 459 | sudo depmod -a ${KERNEL_NAME} |
| 460 | } |
| 461 | |
| 462 | function all { |
| 463 | echo "Running all commands..." |
| 464 | kernel |
| 465 | mn_deps |
| 466 | of |
| 467 | wireshark |
| 468 | ovs |
| 469 | # NOX-classic is deprecated, but you can install it manually if desired. |
| 470 | # nox |
| 471 | pox |
| 472 | oftest |
| 473 | cbench |
| 474 | other |
| 475 | echo "Please reboot, then run ./mininet/util/install.sh -c to remove unneeded packages." |
| 476 | echo "Enjoy Mininet!" |
| 477 | } |
| 478 | |
| 479 | # Restore disk space and remove sensitive files before shipping a VM. |
| 480 | function vm_clean { |
| 481 | echo "Cleaning VM..." |
| 482 | sudo apt-get clean |
| 483 | sudo rm -rf /tmp/* |
| 484 | sudo rm -rf openvswitch*.tar.gz |
| 485 | |
| 486 | # Remove sensistive files |
| 487 | history -c # note this won't work if you have multiple bash sessions |
| 488 | rm -f ~/.bash_history # need to clear in memory and remove on disk |
| 489 | rm -f ~/.ssh/id_rsa* ~/.ssh/known_hosts |
| 490 | sudo rm -f ~/.ssh/authorized_keys* |
| 491 | |
| 492 | # Remove Mininet files |
| 493 | #sudo rm -f /lib/modules/python2.5/site-packages/mininet* |
| 494 | #sudo rm -f /usr/bin/mnexec |
| 495 | |
| 496 | # Clear optional dev script for SSH keychain load on boot |
| 497 | rm -f ~/.bash_profile |
| 498 | |
| 499 | # Clear git changes |
| 500 | git config --global user.name "None" |
| 501 | git config --global user.email "None" |
| 502 | |
| 503 | # Remove mininet install script |
| 504 | rm -f install-mininet.sh |
| 505 | } |
| 506 | |
| 507 | function usage { |
| 508 | printf 'Usage: %s [-acdfhkmntvxy]\n\n' $(basename $0) >&2 |
| 509 | |
| 510 | printf 'This install script attempts to install useful packages\n' >&2 |
| 511 | printf 'for Mininet. It should (hopefully) work on Ubuntu 10.04, 11.10\n' >&2 |
| 512 | printf 'and Debian 5.0 (Lenny). If you run into trouble, try\n' >&2 |
| 513 | printf 'installing one thing at a time, and looking at the \n' >&2 |
| 514 | printf 'specific installation function in this script.\n\n' >&2 |
| 515 | |
| 516 | printf 'options:\n' >&2 |
| 517 | printf -- ' -a: (default) install (A)ll packages - good luck!\n' >&2 |
| 518 | printf -- ' -b: install controller (B)enchmark (oflops)\n' >&2 |
| 519 | printf -- ' -c: (C)lean up after kernel install\n' >&2 |
| 520 | printf -- ' -d: (D)elete some sensitive files from a VM image\n' >&2 |
| 521 | printf -- ' -f: install open(F)low\n' >&2 |
| 522 | printf -- ' -h: print this (H)elp message\n' >&2 |
| 523 | printf -- ' -k: install new (K)ernel\n' >&2 |
| 524 | printf -- ' -m: install Open vSwitch kernel (M)odule from source dir\n' >&2 |
| 525 | printf -- ' -n: install mini(N)et dependencies + core files\n' >&2 |
| 526 | printf -- ' -r: remove existing Open vSwitch packages\n' >&2 |
| 527 | printf -- ' -t: install o(T)her stuff\n' >&2 |
| 528 | printf -- ' -v: install open (V)switch\n' >&2 |
| 529 | printf -- ' -w: install OpenFlow (w)ireshark dissector\n' >&2 |
| 530 | printf -- ' -x: install NO(X) OpenFlow controller\n' >&2 |
| 531 | printf -- ' -y: install (A)ll packages\n' >&2 |
| 532 | |
| 533 | exit 2 |
| 534 | } |
| 535 | |
| 536 | if [ $# -eq 0 ] |
| 537 | then |
| 538 | all |
| 539 | else |
| 540 | while getopts 'abcdfhkmnprtvwx' OPTION |
| 541 | do |
| 542 | case $OPTION in |
| 543 | a) all;; |
| 544 | b) cbench;; |
| 545 | c) kernel_clean;; |
| 546 | d) vm_clean;; |
| 547 | f) of;; |
| 548 | h) usage;; |
| 549 | k) kernel;; |
| 550 | m) modprobe;; |
| 551 | n) mn_deps;; |
| 552 | p) pox;; |
| 553 | r) remove_ovs;; |
| 554 | t) other;; |
| 555 | v) ovs;; |
| 556 | w) wireshark;; |
| 557 | x) nox;; |
| 558 | ?) usage;; |
| 559 | esac |
| 560 | done |
| 561 | shift $(($OPTIND - 1)) |
| 562 | fi |