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