blob: 20a4cd61e3251e3bb06f50e6f7ceec3efe5bd18e [file] [log] [blame]
alshabib3881a142014-11-17 15:04:35 -08001#!/bin/bash
2# vm-setup.sh
3#
4# This script installs ONOS dependencies and installs a desktop environment on a Miniet VM.
5
alshabibff061ee2014-11-17 15:57:10 -08006
7export CURRENT_USER=tutorial1
8export USER_HOME=/home/${CURRENT_USER}
9
10
alshabib3881a142014-11-17 15:04:35 -080011# -------------- Setup keys -------------------
12
alshabibe94a2752014-11-17 18:27:29 -080013mkdir -p ~/.ssh
alshabib3881a142014-11-17 15:04:35 -080014ssh-keygen -t dsa -P "" -f .ssh/id_dsa
15cp .ssh/id_dsa.pub .ssh/authorized_keys
16
alshabibcf82ac72014-12-01 09:42:32 -080017#--------------- Clean Karaf Run --------------
18
19echo "sudo service onos restart" >> ~/.bashrc
20
alshabib3881a142014-11-17 15:04:35 -080021# -------------- Install Karaf ----------------
22
23mkdir Downloads
24cd Downloads
alshabibeeb81302014-11-18 14:12:22 -080025wget http://apache.osuosl.org/karaf/3.0.2/apache-karaf-3.0.2.zip
alshabib3881a142014-11-17 15:04:35 -080026cd -
27
alshabib71ec25a2014-11-18 18:59:46 -080028# -------------- Setup Wireshark dissector ----
29
30wget -O openflow.lua "https://gerrit.onosproject.org/gitweb?p=ONOS-VM.git;a=blob_plain;hb=refs/heads/onos-tutorial;f=openflow.lua"
31mkdir -p .wireshark/plugins
32mv openflow.lua .wireshark/plugins
33
alshabib3881a142014-11-17 15:04:35 -080034# -------------- Setup Desktop ----------------
35
36sudo apt-get install -y xorg lxde
37
38#TODO: add backgrounds folder
alshabibda71cc92014-11-18 16:39:41 -080039sudo mkdir -p /usr/share/backgrounds
alshabib3881a142014-11-17 15:04:35 -080040#TODO: change background
41# Remove wallpaper, change background color
42sudo sed -i 's/wallpaper_mode=1/wallpaper_mode=0/g' /usr/share/lxde/pcmanfm/LXDE.conf
43sudo sed -i 's/desktop_bg=#000000/desktop_bg=#104187/g' /usr/share/lxde/pcmanfm/LXDE.conf
44
45# Automatically start LXDE on login
46echo '[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx' >> ~/.bashrc
47
48# Automatically log into the VM
49#sudo sed -i 's/exec /sbin/getty -8 38400 tty1//g' /etc/init/tty1.conf
50#sudo sed -i '$ d' /etc/init/tty1.conf
51#echo 'exec /bin/login -f bob < /dev/tty1 > /dev/tty1 2>&1' | sudo tee -a /etc/init/tty1.conf
52
53# Disable screensaver
54sudo sed -i '/screensaver/d' /etc/xdg/lxsession/LXDE/autostart
55cat > ${USER_HOME}/.xsessionrc << EOF
56# disable screensaver
57xset s off
58# disable dpms (standby)
59xset -dpms
60EOF
61
62# Change LXTerminal default colors
63#sudo sed -i 's/bgcolor=#000000000000/bgcolor=#ffffffffffff/g' ${USER_HOME}/.config/lxterminal/lxterminal.conf
64#sudo sed -i 's/fgcolor=#aaaaaaaaaaaa/fgcolor=#000000000000/g' ${USER_HOME}/.config/lxterminal/lxterminal.conf
65sudo sed -i 's/bgcolor=#000000000000/bgcolor=#ffffffffffff/g' /usr/share/lxterminal/lxterminal.conf
66sudo sed -i 's/fgcolor=#aaaaaaaaaaaa/fgcolor=#000000000000/g' /usr/share/lxterminal/lxterminal.conf
67
68DESKTOP=${USER_HOME}/Desktop
alshabib3881a142014-11-17 15:04:35 -080069
70mkdir -p ${DESKTOP}
alshabib3881a142014-11-17 15:04:35 -080071
72cat > ${DESKTOP}/ONOS << EOF
73[Desktop Entry]
74Encoding=UTF-8
75Type=Application
alshabibf86bfb32014-11-17 22:30:26 -080076Name=ONOS
77Name[en_US]=ONOS
alshabib3881a142014-11-17 15:04:35 -080078Icon=konsole
alshabib502ad142014-11-19 21:58:23 -080079Exec=/usr/bin/lxterminal -e '/opt/onos/apache-karaf-3.0.2/bin/client -u karaf'
alshabib3881a142014-11-17 15:04:35 -080080Comment[en_US]=
81EOF
82
83cat > ${DESKTOP}/Mininet << EOF
84[Desktop Entry]
85Encoding=UTF-8
86Type=Application
alshabibf86bfb32014-11-17 22:30:26 -080087Name=Mininet
alshabib3881a142014-11-17 15:04:35 -080088Name[en_US]=Mininet
89Icon=konsole
alshabib502ad142014-11-19 21:58:23 -080090Exec=/usr/bin/lxterminal -e 'sudo mn --custom /home/tutorial1/onos-next/tools/test/topos/tower.py --topo tower --controller remote --mac'
alshabib3881a142014-11-17 15:04:35 -080091Comment[en_US]=
92EOF
93
alshabib3881a142014-11-17 15:04:35 -080094cat > ${DESKTOP}/Tutorial << EOF
95[Desktop Entry]
96Encoding=UTF-8
97Type=Application
alshabibf86bfb32014-11-17 22:30:26 -080098Name=ONOS Tutorial
99Name[en_US]=ONOS Tutorial
alshabib3881a142014-11-17 15:04:35 -0800100Icon=internet-web-browser
alshabibf86bfb32014-11-17 22:30:26 -0800101Exec=/usr/bin/chromium-browser https://wiki.onosproject.org/display/ONOS/Basic+ONOS+Tutorial
alshabib3881a142014-11-17 15:04:35 -0800102Comment[en_US]=
103EOF
104
alshabibbf2db602014-11-19 18:13:49 -0800105cat > ${DESKTOP}/GUI << EOF
106[Desktop Entry]
107Encoding=UTF-8
108Type=Application
109Name=ONOS GUI
110Name[en_US]=ONOS GUI
111Icon=internet-web-browser
112Exec=/usr/bin/chromium-browser http://localhost:8181/onos/ui/index2.html#topo
113Comment[en_US]=
114EOF
115
alshabib3881a142014-11-17 15:04:35 -0800116cat > ${DESKTOP}/Wireshark << EOF
117[Desktop Entry]
118Encoding=UTF-8
119Type=Application
120Name=Wireshark
121Name[en_US]=Wireshark
122Icon=wireshark
123Exec=/usr/bin/wireshark
124Comment[en_US]=
125EOF
126
alshabibd348f162014-12-01 10:03:24 -0800127cat > ${DESKTOP}/Reset << EOF
128[Desktop Entry]
129Encoding=UTF-8
130Type=Application
131Name=Reset
132Name[en_US]=Reset
133Icon=konsole
134Exec=/usr/bin/lxterminal -t 'Resetting; please wait' -e 'sudo service onos restart'
135Comment[en_US]=
136EOF
137
alshabib3881a142014-11-17 15:04:35 -0800138# ------------- Install Other Tools -------------
139sudo apt-get install -y wireshark
140# Enable root-less wireshark and add mininet
141echo "Enabling wireshark group"
142echo "wireshark-common wireshark-common/install-setuid boolean true" | sudo debconf-set-selections
143sudo dpkg-reconfigure -f noninteractive wireshark-common
144sudo usermod -a -G wireshark mininet
alshabibd4da55d2014-11-19 19:31:30 -0800145sudo usermod -a -G wireshark tutorial1
146
alshabib3881a142014-11-17 15:04:35 -0800147
148echo "Installing VirtualBox Guest Additions"
149sudo apt-get install -y virtualbox-guest-x11
150
151# ------------- Zero Unused Blocks -------------
152#TODO investigate zerofree
153echo "Zeroing unused blocks"
154sync
155dd if=/dev/zero of=tmp-zeros
156sync
157rm tmp-zeros
158sync