blob: dd855dc7a14e7f8cf1109abf0f196321c69de6c6 [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
alshabib3881a142014-11-17 15:04:35 -080030# -------------- Setup Desktop ----------------
31
32sudo apt-get install -y xorg lxde
33
34#TODO: add backgrounds folder
alshabibda71cc92014-11-18 16:39:41 -080035sudo mkdir -p /usr/share/backgrounds
alshabib3881a142014-11-17 15:04:35 -080036#TODO: change background
37# Remove wallpaper, change background color
38sudo sed -i 's/wallpaper_mode=1/wallpaper_mode=0/g' /usr/share/lxde/pcmanfm/LXDE.conf
39sudo sed -i 's/desktop_bg=#000000/desktop_bg=#104187/g' /usr/share/lxde/pcmanfm/LXDE.conf
40
41# Automatically start LXDE on login
42echo '[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx' >> ~/.bashrc
43
44# Automatically log into the VM
45#sudo sed -i 's/exec /sbin/getty -8 38400 tty1//g' /etc/init/tty1.conf
46#sudo sed -i '$ d' /etc/init/tty1.conf
47#echo 'exec /bin/login -f bob < /dev/tty1 > /dev/tty1 2>&1' | sudo tee -a /etc/init/tty1.conf
48
49# Disable screensaver
50sudo sed -i '/screensaver/d' /etc/xdg/lxsession/LXDE/autostart
51cat > ${USER_HOME}/.xsessionrc << EOF
52# disable screensaver
53xset s off
54# disable dpms (standby)
55xset -dpms
56EOF
57
58# Change LXTerminal default colors
59#sudo sed -i 's/bgcolor=#000000000000/bgcolor=#ffffffffffff/g' ${USER_HOME}/.config/lxterminal/lxterminal.conf
60#sudo sed -i 's/fgcolor=#aaaaaaaaaaaa/fgcolor=#000000000000/g' ${USER_HOME}/.config/lxterminal/lxterminal.conf
61sudo sed -i 's/bgcolor=#000000000000/bgcolor=#ffffffffffff/g' /usr/share/lxterminal/lxterminal.conf
62sudo sed -i 's/fgcolor=#aaaaaaaaaaaa/fgcolor=#000000000000/g' /usr/share/lxterminal/lxterminal.conf
63
64DESKTOP=${USER_HOME}/Desktop
alshabib3881a142014-11-17 15:04:35 -080065
66mkdir -p ${DESKTOP}
alshabib3881a142014-11-17 15:04:35 -080067
68cat > ${DESKTOP}/ONOS << EOF
69[Desktop Entry]
70Encoding=UTF-8
71Type=Application
alshabibf86bfb32014-11-17 22:30:26 -080072Name=ONOS
73Name[en_US]=ONOS
alshabib3881a142014-11-17 15:04:35 -080074Icon=konsole
75Exec=/usr/bin/xterm -e '/opt/onos/apache-karaf-3.0.2/bin/client -u karaf'
76Comment[en_US]=
77EOF
78
79cat > ${DESKTOP}/Mininet << EOF
80[Desktop Entry]
81Encoding=UTF-8
82Type=Application
alshabibf86bfb32014-11-17 22:30:26 -080083Name=Mininet
alshabib3881a142014-11-17 15:04:35 -080084Name[en_US]=Mininet
85Icon=konsole
alshabibcfb22b72014-11-18 16:58:15 -080086Exec=/usr/bin/xterm -e 'sudo mn --custom ~/onos-next/tools/test/topos/tower.py --topo tower --controller remote --mac'
alshabib3881a142014-11-17 15:04:35 -080087Comment[en_US]=
88EOF
89
alshabib3881a142014-11-17 15:04:35 -080090cat > ${DESKTOP}/Tutorial << EOF
91[Desktop Entry]
92Encoding=UTF-8
93Type=Application
alshabibf86bfb32014-11-17 22:30:26 -080094Name=ONOS Tutorial
95Name[en_US]=ONOS Tutorial
alshabib3881a142014-11-17 15:04:35 -080096Icon=internet-web-browser
alshabibf86bfb32014-11-17 22:30:26 -080097Exec=/usr/bin/chromium-browser https://wiki.onosproject.org/display/ONOS/Basic+ONOS+Tutorial
alshabib3881a142014-11-17 15:04:35 -080098Comment[en_US]=
99EOF
100
101cat > ${DESKTOP}/Wireshark << EOF
102[Desktop Entry]
103Encoding=UTF-8
104Type=Application
105Name=Wireshark
106Name[en_US]=Wireshark
107Icon=wireshark
108Exec=/usr/bin/wireshark
109Comment[en_US]=
110EOF
111
112# ------------- Install Other Tools -------------
113sudo apt-get install -y wireshark
114# Enable root-less wireshark and add mininet
115echo "Enabling wireshark group"
116echo "wireshark-common wireshark-common/install-setuid boolean true" | sudo debconf-set-selections
117sudo dpkg-reconfigure -f noninteractive wireshark-common
118sudo usermod -a -G wireshark mininet
119
120echo "Installing VirtualBox Guest Additions"
121sudo apt-get install -y virtualbox-guest-x11
122
123# ------------- Zero Unused Blocks -------------
124#TODO investigate zerofree
125echo "Zeroing unused blocks"
126sync
127dd if=/dev/zero of=tmp-zeros
128sync
129rm tmp-zeros
130sync