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