blob: 469327bea2c21b0127d873186c042d66ad7e204f [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
17# -------------- Install Karaf ----------------
18
19mkdir Downloads
20cd Downloads
alshabibeeb81302014-11-18 14:12:22 -080021wget http://apache.osuosl.org/karaf/3.0.2/apache-karaf-3.0.2.zip
alshabib3881a142014-11-17 15:04:35 -080022cd -
23
alshabib71ec25a2014-11-18 18:59:46 -080024# -------------- Setup Wireshark dissector ----
25
26wget -O openflow.lua "https://gerrit.onosproject.org/gitweb?p=ONOS-VM.git;a=blob_plain;hb=refs/heads/onos-tutorial;f=openflow.lua"
27mkdir -p .wireshark/plugins
28mv openflow.lua .wireshark/plugins
29
alshabibc7d2b8f2014-12-01 19:28:54 -080030
31
alshabib3881a142014-11-17 15:04:35 -080032# -------------- Setup Desktop ----------------
33
34sudo apt-get install -y xorg lxde
35
36#TODO: add backgrounds folder
alshabibda71cc92014-11-18 16:39:41 -080037sudo mkdir -p /usr/share/backgrounds
alshabib3881a142014-11-17 15:04:35 -080038#TODO: change background
39# Remove wallpaper, change background color
40sudo sed -i 's/wallpaper_mode=1/wallpaper_mode=0/g' /usr/share/lxde/pcmanfm/LXDE.conf
41sudo sed -i 's/desktop_bg=#000000/desktop_bg=#104187/g' /usr/share/lxde/pcmanfm/LXDE.conf
42
alshabibc7d2b8f2014-12-01 19:28:54 -080043sudo sed -i 's/lang=1/lang=0/g' /etc/lxdm/default.conf
44sudo sed -i 's/bottom_pane=1/bottom_pane=0/g' /etc/lxdm/default.conf
45sudo sed -i 's/disable=0/diable=1/g' /etc/lxdm/default.conf
46
47
48wget -O onos.png "https://gerrit.onosproject.org/gitweb?p=ONOS-VM.git;a=blob_plain;hb=refs/heads/onos-tutorial;f=onos.png"
49cp onos.png /usr/share/backgrounds/default.png
50
alshabib3881a142014-11-17 15:04:35 -080051# Automatically start LXDE on login
52echo '[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx' >> ~/.bashrc
53
54# Automatically log into the VM
55#sudo sed -i 's/exec /sbin/getty -8 38400 tty1//g' /etc/init/tty1.conf
56#sudo sed -i '$ d' /etc/init/tty1.conf
57#echo 'exec /bin/login -f bob < /dev/tty1 > /dev/tty1 2>&1' | sudo tee -a /etc/init/tty1.conf
58
59# Disable screensaver
60sudo sed -i '/screensaver/d' /etc/xdg/lxsession/LXDE/autostart
61cat > ${USER_HOME}/.xsessionrc << EOF
62# disable screensaver
63xset s off
64# disable dpms (standby)
65xset -dpms
66EOF
67
68# Change LXTerminal default colors
69#sudo sed -i 's/bgcolor=#000000000000/bgcolor=#ffffffffffff/g' ${USER_HOME}/.config/lxterminal/lxterminal.conf
70#sudo sed -i 's/fgcolor=#aaaaaaaaaaaa/fgcolor=#000000000000/g' ${USER_HOME}/.config/lxterminal/lxterminal.conf
71sudo sed -i 's/bgcolor=#000000000000/bgcolor=#ffffffffffff/g' /usr/share/lxterminal/lxterminal.conf
72sudo sed -i 's/fgcolor=#aaaaaaaaaaaa/fgcolor=#000000000000/g' /usr/share/lxterminal/lxterminal.conf
73
74DESKTOP=${USER_HOME}/Desktop
alshabib3881a142014-11-17 15:04:35 -080075
76mkdir -p ${DESKTOP}
alshabib3881a142014-11-17 15:04:35 -080077
78cat > ${DESKTOP}/ONOS << EOF
79[Desktop Entry]
80Encoding=UTF-8
81Type=Application
alshabibf86bfb32014-11-17 22:30:26 -080082Name=ONOS
83Name[en_US]=ONOS
alshabib3881a142014-11-17 15:04:35 -080084Icon=konsole
alshabib502ad142014-11-19 21:58:23 -080085Exec=/usr/bin/lxterminal -e '/opt/onos/apache-karaf-3.0.2/bin/client -u karaf'
alshabib3881a142014-11-17 15:04:35 -080086Comment[en_US]=
87EOF
88
89cat > ${DESKTOP}/Mininet << EOF
90[Desktop Entry]
91Encoding=UTF-8
92Type=Application
alshabibf86bfb32014-11-17 22:30:26 -080093Name=Mininet
alshabib3881a142014-11-17 15:04:35 -080094Name[en_US]=Mininet
95Icon=konsole
alshabib502ad142014-11-19 21:58:23 -080096Exec=/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 -080097Comment[en_US]=
98EOF
99
alshabib3881a142014-11-17 15:04:35 -0800100cat > ${DESKTOP}/Tutorial << EOF
101[Desktop Entry]
102Encoding=UTF-8
103Type=Application
alshabibf86bfb32014-11-17 22:30:26 -0800104Name=ONOS Tutorial
105Name[en_US]=ONOS Tutorial
alshabib3881a142014-11-17 15:04:35 -0800106Icon=internet-web-browser
alshabibf86bfb32014-11-17 22:30:26 -0800107Exec=/usr/bin/chromium-browser https://wiki.onosproject.org/display/ONOS/Basic+ONOS+Tutorial
alshabib3881a142014-11-17 15:04:35 -0800108Comment[en_US]=
109EOF
110
alshabibbf2db602014-11-19 18:13:49 -0800111cat > ${DESKTOP}/GUI << EOF
112[Desktop Entry]
113Encoding=UTF-8
114Type=Application
115Name=ONOS GUI
116Name[en_US]=ONOS GUI
117Icon=internet-web-browser
alshabibd496de22014-12-01 17:36:56 -0800118Exec=/usr/bin/chromium-browser http://localhost:8181/onos/ui/index.html#topo
alshabibbf2db602014-11-19 18:13:49 -0800119Comment[en_US]=
120EOF
121
alshabib3881a142014-11-17 15:04:35 -0800122cat > ${DESKTOP}/Wireshark << EOF
123[Desktop Entry]
124Encoding=UTF-8
125Type=Application
126Name=Wireshark
127Name[en_US]=Wireshark
128Icon=wireshark
129Exec=/usr/bin/wireshark
130Comment[en_US]=
131EOF
132
alshabibd348f162014-12-01 10:03:24 -0800133cat > ${DESKTOP}/Reset << EOF
134[Desktop Entry]
135Encoding=UTF-8
136Type=Application
137Name=Reset
138Name[en_US]=Reset
139Icon=konsole
140Exec=/usr/bin/lxterminal -t 'Resetting; please wait' -e 'sudo service onos restart'
141Comment[en_US]=
142EOF
143
alshabib3881a142014-11-17 15:04:35 -0800144# ------------- Install Other Tools -------------
145sudo apt-get install -y wireshark
146# Enable root-less wireshark and add mininet
147echo "Enabling wireshark group"
148echo "wireshark-common wireshark-common/install-setuid boolean true" | sudo debconf-set-selections
149sudo dpkg-reconfigure -f noninteractive wireshark-common
150sudo usermod -a -G wireshark mininet
alshabibd4da55d2014-11-19 19:31:30 -0800151sudo usermod -a -G wireshark tutorial1
152
alshabib3881a142014-11-17 15:04:35 -0800153
154echo "Installing VirtualBox Guest Additions"
155sudo apt-get install -y virtualbox-guest-x11
156
157# ------------- Zero Unused Blocks -------------
158#TODO investigate zerofree
159echo "Zeroing unused blocks"
160sync
161dd if=/dev/zero of=tmp-zeros
162sync
163rm tmp-zeros
164sync