alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # vm-setup.sh |
| 3 | # |
| 4 | # This script installs ONOS dependencies and installs a desktop environment on a Miniet VM. |
| 5 | |
alshabib | ff061ee | 2014-11-17 15:57:10 -0800 | [diff] [blame] | 6 | |
| 7 | export CURRENT_USER=tutorial1 |
| 8 | export USER_HOME=/home/${CURRENT_USER} |
| 9 | |
| 10 | |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 11 | # -------------- Setup keys ------------------- |
| 12 | |
alshabib | e94a275 | 2014-11-17 18:27:29 -0800 | [diff] [blame] | 13 | mkdir -p ~/.ssh |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 14 | ssh-keygen -t dsa -P "" -f .ssh/id_dsa |
| 15 | cp .ssh/id_dsa.pub .ssh/authorized_keys |
| 16 | |
| 17 | # -------------- Install Karaf ---------------- |
| 18 | |
| 19 | mkdir Downloads |
| 20 | cd Downloads |
alshabib | eeb8130 | 2014-11-18 14:12:22 -0800 | [diff] [blame] | 21 | wget http://apache.osuosl.org/karaf/3.0.2/apache-karaf-3.0.2.zip |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 22 | cd - |
| 23 | |
alshabib | 71ec25a | 2014-11-18 18:59:46 -0800 | [diff] [blame] | 24 | # -------------- Setup Wireshark dissector ---- |
| 25 | |
Jonathan Hart | 449f446 | 2014-12-04 15:37:46 -0800 | [diff] [blame] | 26 | wget -O openflow.lua "https://gerrit.onosproject.org/gitweb?p=onos-vm.git;a=blob_plain;hb=refs/heads/onos-tutorial;f=openflow.lua" |
alshabib | 71ec25a | 2014-11-18 18:59:46 -0800 | [diff] [blame] | 27 | mkdir -p .wireshark/plugins |
| 28 | mv openflow.lua .wireshark/plugins |
| 29 | |
alshabib | c7d2b8f | 2014-12-01 19:28:54 -0800 | [diff] [blame] | 30 | |
| 31 | |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 32 | # -------------- Setup Desktop ---------------- |
| 33 | |
Marc De Leenheer | 9a53196 | 2015-01-14 16:42:11 -0800 | [diff] [blame] | 34 | sudo apt-get install -y xorg lxde systemd-shim |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 35 | |
| 36 | #TODO: add backgrounds folder |
alshabib | da71cc9 | 2014-11-18 16:39:41 -0800 | [diff] [blame] | 37 | sudo mkdir -p /usr/share/backgrounds |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 38 | #TODO: change background |
| 39 | # Remove wallpaper, change background color |
| 40 | sudo sed -i 's/wallpaper_mode=1/wallpaper_mode=0/g' /usr/share/lxde/pcmanfm/LXDE.conf |
| 41 | sudo sed -i 's/desktop_bg=#000000/desktop_bg=#104187/g' /usr/share/lxde/pcmanfm/LXDE.conf |
| 42 | |
alshabib | c7d2b8f | 2014-12-01 19:28:54 -0800 | [diff] [blame] | 43 | sudo sed -i 's/lang=1/lang=0/g' /etc/lxdm/default.conf |
| 44 | sudo sed -i 's/bottom_pane=1/bottom_pane=0/g' /etc/lxdm/default.conf |
alshabib | 8b1bb6e | 2014-12-01 20:01:39 -0800 | [diff] [blame] | 45 | sudo sed -i 's/disable=0/disable=1/g' /etc/lxdm/default.conf |
alshabib | c7d2b8f | 2014-12-01 19:28:54 -0800 | [diff] [blame] | 46 | |
Marc De Leenheer | 9a53196 | 2015-01-14 16:42:11 -0800 | [diff] [blame] | 47 | # Allow VM to be rebooted from GUI |
Marc De Leenheer | 59b0ced | 2015-01-15 14:35:44 -0800 | [diff] [blame] | 48 | echo "session required pam_systemd.so" | sudo tee --append /etc/pam.d/lxdm |
alshabib | c7d2b8f | 2014-12-01 19:28:54 -0800 | [diff] [blame] | 49 | |
Jonathan Hart | 449f446 | 2014-12-04 15:37:46 -0800 | [diff] [blame] | 50 | wget -O onos.png "https://gerrit.onosproject.org/gitweb?p=onos-vm.git;a=blob_plain;hb=refs/heads/onos-tutorial;f=onos.png" |
alshabib | 8b1bb6e | 2014-12-01 20:01:39 -0800 | [diff] [blame] | 51 | sudo cp onos.png /usr/share/backgrounds/default.png |
alshabib | c7d2b8f | 2014-12-01 19:28:54 -0800 | [diff] [blame] | 52 | |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 53 | # Automatically start LXDE on login |
| 54 | echo '[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx' >> ~/.bashrc |
| 55 | |
| 56 | # Automatically log into the VM |
| 57 | #sudo sed -i 's/exec /sbin/getty -8 38400 tty1//g' /etc/init/tty1.conf |
| 58 | #sudo sed -i '$ d' /etc/init/tty1.conf |
| 59 | #echo 'exec /bin/login -f bob < /dev/tty1 > /dev/tty1 2>&1' | sudo tee -a /etc/init/tty1.conf |
| 60 | |
Marc De Leenheer | b75cb13 | 2015-01-16 10:06:02 -0800 | [diff] [blame] | 61 | echo "sudo service onos start > /dev/null 2>&1" >> ~/.profile |
| 62 | |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 63 | # Disable screensaver |
| 64 | sudo sed -i '/screensaver/d' /etc/xdg/lxsession/LXDE/autostart |
| 65 | cat > ${USER_HOME}/.xsessionrc << EOF |
| 66 | # disable screensaver |
| 67 | xset s off |
| 68 | # disable dpms (standby) |
| 69 | xset -dpms |
| 70 | EOF |
| 71 | |
| 72 | # Change LXTerminal default colors |
| 73 | #sudo sed -i 's/bgcolor=#000000000000/bgcolor=#ffffffffffff/g' ${USER_HOME}/.config/lxterminal/lxterminal.conf |
| 74 | #sudo sed -i 's/fgcolor=#aaaaaaaaaaaa/fgcolor=#000000000000/g' ${USER_HOME}/.config/lxterminal/lxterminal.conf |
| 75 | sudo sed -i 's/bgcolor=#000000000000/bgcolor=#ffffffffffff/g' /usr/share/lxterminal/lxterminal.conf |
| 76 | sudo sed -i 's/fgcolor=#aaaaaaaaaaaa/fgcolor=#000000000000/g' /usr/share/lxterminal/lxterminal.conf |
| 77 | |
| 78 | DESKTOP=${USER_HOME}/Desktop |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 79 | |
| 80 | mkdir -p ${DESKTOP} |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 81 | |
| 82 | cat > ${DESKTOP}/ONOS << EOF |
| 83 | [Desktop Entry] |
| 84 | Encoding=UTF-8 |
| 85 | Type=Application |
alshabib | f86bfb3 | 2014-11-17 22:30:26 -0800 | [diff] [blame] | 86 | Name=ONOS |
| 87 | Name[en_US]=ONOS |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 88 | Icon=konsole |
alshabib | 502ad14 | 2014-11-19 21:58:23 -0800 | [diff] [blame] | 89 | Exec=/usr/bin/lxterminal -e '/opt/onos/apache-karaf-3.0.2/bin/client -u karaf' |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 90 | Comment[en_US]= |
| 91 | EOF |
| 92 | |
| 93 | cat > ${DESKTOP}/Mininet << EOF |
| 94 | [Desktop Entry] |
| 95 | Encoding=UTF-8 |
| 96 | Type=Application |
alshabib | f86bfb3 | 2014-11-17 22:30:26 -0800 | [diff] [blame] | 97 | Name=Mininet |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 98 | Name[en_US]=Mininet |
| 99 | Icon=konsole |
Jonathan Hart | 622597b | 2014-12-04 13:15:50 -0800 | [diff] [blame] | 100 | Exec=/usr/bin/lxterminal -e 'sudo mn --custom /home/tutorial1/onos/tools/test/topos/tower.py --topo tower --controller remote --mac' |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 101 | Comment[en_US]= |
| 102 | EOF |
| 103 | |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 104 | cat > ${DESKTOP}/Tutorial << EOF |
| 105 | [Desktop Entry] |
| 106 | Encoding=UTF-8 |
| 107 | Type=Application |
alshabib | f86bfb3 | 2014-11-17 22:30:26 -0800 | [diff] [blame] | 108 | Name=ONOS Tutorial |
| 109 | Name[en_US]=ONOS Tutorial |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 110 | Icon=internet-web-browser |
alshabib | f86bfb3 | 2014-11-17 22:30:26 -0800 | [diff] [blame] | 111 | Exec=/usr/bin/chromium-browser https://wiki.onosproject.org/display/ONOS/Basic+ONOS+Tutorial |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 112 | Comment[en_US]= |
| 113 | EOF |
| 114 | |
alshabib | bf2db60 | 2014-11-19 18:13:49 -0800 | [diff] [blame] | 115 | cat > ${DESKTOP}/GUI << EOF |
| 116 | [Desktop Entry] |
| 117 | Encoding=UTF-8 |
| 118 | Type=Application |
| 119 | Name=ONOS GUI |
| 120 | Name[en_US]=ONOS GUI |
| 121 | Icon=internet-web-browser |
alshabib | d496de2 | 2014-12-01 17:36:56 -0800 | [diff] [blame] | 122 | Exec=/usr/bin/chromium-browser http://localhost:8181/onos/ui/index.html#topo |
alshabib | bf2db60 | 2014-11-19 18:13:49 -0800 | [diff] [blame] | 123 | Comment[en_US]= |
| 124 | EOF |
| 125 | |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 126 | cat > ${DESKTOP}/Wireshark << EOF |
| 127 | [Desktop Entry] |
| 128 | Encoding=UTF-8 |
| 129 | Type=Application |
| 130 | Name=Wireshark |
| 131 | Name[en_US]=Wireshark |
| 132 | Icon=wireshark |
| 133 | Exec=/usr/bin/wireshark |
| 134 | Comment[en_US]= |
| 135 | EOF |
| 136 | |
alshabib | d348f16 | 2014-12-01 10:03:24 -0800 | [diff] [blame] | 137 | cat > ${DESKTOP}/Reset << EOF |
| 138 | [Desktop Entry] |
| 139 | Encoding=UTF-8 |
| 140 | Type=Application |
| 141 | Name=Reset |
| 142 | Name[en_US]=Reset |
| 143 | Icon=konsole |
| 144 | Exec=/usr/bin/lxterminal -t 'Resetting; please wait' -e 'sudo service onos restart' |
| 145 | Comment[en_US]= |
| 146 | EOF |
| 147 | |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 148 | # ------------- Install Other Tools ------------- |
| 149 | sudo apt-get install -y wireshark |
| 150 | # Enable root-less wireshark and add mininet |
| 151 | echo "Enabling wireshark group" |
| 152 | echo "wireshark-common wireshark-common/install-setuid boolean true" | sudo debconf-set-selections |
| 153 | sudo dpkg-reconfigure -f noninteractive wireshark-common |
| 154 | sudo usermod -a -G wireshark mininet |
alshabib | d4da55d | 2014-11-19 19:31:30 -0800 | [diff] [blame] | 155 | sudo usermod -a -G wireshark tutorial1 |
| 156 | |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 157 | |
| 158 | echo "Installing VirtualBox Guest Additions" |
| 159 | sudo apt-get install -y virtualbox-guest-x11 |
| 160 | |
| 161 | # ------------- Zero Unused Blocks ------------- |
| 162 | #TODO investigate zerofree |
| 163 | echo "Zeroing unused blocks" |
| 164 | sync |
| 165 | dd if=/dev/zero of=tmp-zeros |
| 166 | sync |
| 167 | rm tmp-zeros |
| 168 | sync |