blob: ead3f6447a8251f923942ded9443a04c6634254c [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
127# ------------- Install Other Tools -------------
128sudo apt-get install -y wireshark
129# Enable root-less wireshark and add mininet
130echo "Enabling wireshark group"
131echo "wireshark-common wireshark-common/install-setuid boolean true" | sudo debconf-set-selections
132sudo dpkg-reconfigure -f noninteractive wireshark-common
133sudo usermod -a -G wireshark mininet
alshabibd4da55d2014-11-19 19:31:30 -0800134sudo usermod -a -G wireshark tutorial1
135
alshabib3881a142014-11-17 15:04:35 -0800136
137echo "Installing VirtualBox Guest Additions"
138sudo apt-get install -y virtualbox-guest-x11
139
140# ------------- Zero Unused Blocks -------------
141#TODO investigate zerofree
142echo "Zeroing unused blocks"
143sync
144dd if=/dev/zero of=tmp-zeros
145sync
146rm tmp-zeros
147sync