blob: ca1950fe220382e3d170f62ac832a712c64daf67 [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
13ssh-keygen -t dsa -P "" -f .ssh/id_dsa
14cp .ssh/id_dsa.pub .ssh/authorized_keys
15
16# -------------- Install Karaf ----------------
17
18mkdir Downloads
19cd Downloads
20wget http://mirror.nexcess.net/apache/karaf/3.0.2/apache-karaf-3.0.2.zip
21cd -
22
23# -------------- Setup Desktop ----------------
24
25sudo apt-get install -y xorg lxde
26
27#TODO: add backgrounds folder
28sudo mkdir /usr/share/backgrounds
29#TODO: change background
30# Remove wallpaper, change background color
31sudo sed -i 's/wallpaper_mode=1/wallpaper_mode=0/g' /usr/share/lxde/pcmanfm/LXDE.conf
32sudo sed -i 's/desktop_bg=#000000/desktop_bg=#104187/g' /usr/share/lxde/pcmanfm/LXDE.conf
33
34# Automatically start LXDE on login
35echo '[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx' >> ~/.bashrc
36
37# Automatically log into the VM
38#sudo sed -i 's/exec /sbin/getty -8 38400 tty1//g' /etc/init/tty1.conf
39#sudo sed -i '$ d' /etc/init/tty1.conf
40#echo 'exec /bin/login -f bob < /dev/tty1 > /dev/tty1 2>&1' | sudo tee -a /etc/init/tty1.conf
41
42# Disable screensaver
43sudo sed -i '/screensaver/d' /etc/xdg/lxsession/LXDE/autostart
44cat > ${USER_HOME}/.xsessionrc << EOF
45# disable screensaver
46xset s off
47# disable dpms (standby)
48xset -dpms
49EOF
50
51# Change LXTerminal default colors
52#sudo sed -i 's/bgcolor=#000000000000/bgcolor=#ffffffffffff/g' ${USER_HOME}/.config/lxterminal/lxterminal.conf
53#sudo sed -i 's/fgcolor=#aaaaaaaaaaaa/fgcolor=#000000000000/g' ${USER_HOME}/.config/lxterminal/lxterminal.conf
54sudo sed -i 's/bgcolor=#000000000000/bgcolor=#ffffffffffff/g' /usr/share/lxterminal/lxterminal.conf
55sudo sed -i 's/fgcolor=#aaaaaaaaaaaa/fgcolor=#000000000000/g' /usr/share/lxterminal/lxterminal.conf
56
57DESKTOP=${USER_HOME}/Desktop
58OFFLINE="${DESKTOP}/Offline Exercises"
59
60mkdir -p ${DESKTOP}
61mkdir -p "${OFFLINE}"
62
63cat > ${DESKTOP}/ONOS << EOF
64[Desktop Entry]
65Encoding=UTF-8
66Type=Application
67Name=Terminal
68Name[en_US]=Terminal
69Icon=konsole
70Exec=/usr/bin/xterm -e '/opt/onos/apache-karaf-3.0.2/bin/client -u karaf'
71Comment[en_US]=
72EOF
73
74cat > ${DESKTOP}/Mininet << EOF
75[Desktop Entry]
76Encoding=UTF-8
77Type=Application
78Name=Terminal
79Name[en_US]=Mininet
80Icon=konsole
81Exec=/usr/bin/xterm -e 'sudo python ~/onos-next/tools/test/topos/sol.py 127.0.0.1'
82Comment[en_US]=
83EOF
84
85
86
87cat > ${DESKTOP}/Tutorial << EOF
88[Desktop Entry]
89Encoding=UTF-8
90Type=Application
91Name=Teaching with Mininet
92Name[en_US]=Teaching with Mininet
93Icon=internet-web-browser
94Exec=/usr/bin/chromium-browser http://teaching.mininet.org
95Comment[en_US]=
96EOF
97
98cat > ${DESKTOP}/Wireshark << EOF
99[Desktop Entry]
100Encoding=UTF-8
101Type=Application
102Name=Wireshark
103Name[en_US]=Wireshark
104Icon=wireshark
105Exec=/usr/bin/wireshark
106Comment[en_US]=
107EOF
108
109# ------------- Install Other Tools -------------
110sudo apt-get install -y wireshark
111# Enable root-less wireshark and add mininet
112echo "Enabling wireshark group"
113echo "wireshark-common wireshark-common/install-setuid boolean true" | sudo debconf-set-selections
114sudo dpkg-reconfigure -f noninteractive wireshark-common
115sudo usermod -a -G wireshark mininet
116
117echo "Installing VirtualBox Guest Additions"
118sudo apt-get install -y virtualbox-guest-x11
119
120# ------------- Zero Unused Blocks -------------
121#TODO investigate zerofree
122echo "Zeroing unused blocks"
123sync
124dd if=/dev/zero of=tmp-zeros
125sync
126rm tmp-zeros
127sync