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 | |
| 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" |
| 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 | |
| 34 | sudo apt-get install -y xorg lxde |
| 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 | |
| 47 | |
| 48 | 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] | 49 | sudo cp onos.png /usr/share/backgrounds/default.png |
alshabib | c7d2b8f | 2014-12-01 19:28:54 -0800 | [diff] [blame] | 50 | |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 51 | # Automatically start LXDE on login |
| 52 | echo '[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx' >> ~/.bashrc |
| 53 | |
| 54 | # Automatically log into the VM |
| 55 | #sudo sed -i 's/exec /sbin/getty -8 38400 tty1//g' /etc/init/tty1.conf |
| 56 | #sudo sed -i '$ d' /etc/init/tty1.conf |
| 57 | #echo 'exec /bin/login -f bob < /dev/tty1 > /dev/tty1 2>&1' | sudo tee -a /etc/init/tty1.conf |
| 58 | |
| 59 | # Disable screensaver |
| 60 | sudo sed -i '/screensaver/d' /etc/xdg/lxsession/LXDE/autostart |
| 61 | cat > ${USER_HOME}/.xsessionrc << EOF |
| 62 | # disable screensaver |
| 63 | xset s off |
| 64 | # disable dpms (standby) |
| 65 | xset -dpms |
| 66 | EOF |
| 67 | |
| 68 | # Change LXTerminal default colors |
| 69 | #sudo sed -i 's/bgcolor=#000000000000/bgcolor=#ffffffffffff/g' ${USER_HOME}/.config/lxterminal/lxterminal.conf |
| 70 | #sudo sed -i 's/fgcolor=#aaaaaaaaaaaa/fgcolor=#000000000000/g' ${USER_HOME}/.config/lxterminal/lxterminal.conf |
| 71 | sudo sed -i 's/bgcolor=#000000000000/bgcolor=#ffffffffffff/g' /usr/share/lxterminal/lxterminal.conf |
| 72 | sudo sed -i 's/fgcolor=#aaaaaaaaaaaa/fgcolor=#000000000000/g' /usr/share/lxterminal/lxterminal.conf |
| 73 | |
| 74 | DESKTOP=${USER_HOME}/Desktop |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 75 | |
| 76 | mkdir -p ${DESKTOP} |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 77 | |
| 78 | cat > ${DESKTOP}/ONOS << EOF |
| 79 | [Desktop Entry] |
| 80 | Encoding=UTF-8 |
| 81 | Type=Application |
alshabib | f86bfb3 | 2014-11-17 22:30:26 -0800 | [diff] [blame] | 82 | Name=ONOS |
| 83 | Name[en_US]=ONOS |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 84 | Icon=konsole |
alshabib | 502ad14 | 2014-11-19 21:58:23 -0800 | [diff] [blame] | 85 | 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] | 86 | Comment[en_US]= |
| 87 | EOF |
| 88 | |
| 89 | cat > ${DESKTOP}/Mininet << EOF |
| 90 | [Desktop Entry] |
| 91 | Encoding=UTF-8 |
| 92 | Type=Application |
alshabib | f86bfb3 | 2014-11-17 22:30:26 -0800 | [diff] [blame] | 93 | Name=Mininet |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 94 | Name[en_US]=Mininet |
| 95 | Icon=konsole |
alshabib | 502ad14 | 2014-11-19 21:58:23 -0800 | [diff] [blame] | 96 | Exec=/usr/bin/lxterminal -e 'sudo mn --custom /home/tutorial1/onos-next/tools/test/topos/tower.py --topo tower --controller remote --mac' |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 97 | Comment[en_US]= |
| 98 | EOF |
| 99 | |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 100 | cat > ${DESKTOP}/Tutorial << EOF |
| 101 | [Desktop Entry] |
| 102 | Encoding=UTF-8 |
| 103 | Type=Application |
alshabib | f86bfb3 | 2014-11-17 22:30:26 -0800 | [diff] [blame] | 104 | Name=ONOS Tutorial |
| 105 | Name[en_US]=ONOS Tutorial |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 106 | Icon=internet-web-browser |
alshabib | f86bfb3 | 2014-11-17 22:30:26 -0800 | [diff] [blame] | 107 | 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] | 108 | Comment[en_US]= |
| 109 | EOF |
| 110 | |
alshabib | bf2db60 | 2014-11-19 18:13:49 -0800 | [diff] [blame] | 111 | cat > ${DESKTOP}/GUI << EOF |
| 112 | [Desktop Entry] |
| 113 | Encoding=UTF-8 |
| 114 | Type=Application |
| 115 | Name=ONOS GUI |
| 116 | Name[en_US]=ONOS GUI |
| 117 | Icon=internet-web-browser |
alshabib | d496de2 | 2014-12-01 17:36:56 -0800 | [diff] [blame] | 118 | Exec=/usr/bin/chromium-browser http://localhost:8181/onos/ui/index.html#topo |
alshabib | bf2db60 | 2014-11-19 18:13:49 -0800 | [diff] [blame] | 119 | Comment[en_US]= |
| 120 | EOF |
| 121 | |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 122 | cat > ${DESKTOP}/Wireshark << EOF |
| 123 | [Desktop Entry] |
| 124 | Encoding=UTF-8 |
| 125 | Type=Application |
| 126 | Name=Wireshark |
| 127 | Name[en_US]=Wireshark |
| 128 | Icon=wireshark |
| 129 | Exec=/usr/bin/wireshark |
| 130 | Comment[en_US]= |
| 131 | EOF |
| 132 | |
alshabib | d348f16 | 2014-12-01 10:03:24 -0800 | [diff] [blame] | 133 | cat > ${DESKTOP}/Reset << EOF |
| 134 | [Desktop Entry] |
| 135 | Encoding=UTF-8 |
| 136 | Type=Application |
| 137 | Name=Reset |
| 138 | Name[en_US]=Reset |
| 139 | Icon=konsole |
| 140 | Exec=/usr/bin/lxterminal -t 'Resetting; please wait' -e 'sudo service onos restart' |
| 141 | Comment[en_US]= |
| 142 | EOF |
| 143 | |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 144 | # ------------- Install Other Tools ------------- |
| 145 | sudo apt-get install -y wireshark |
| 146 | # Enable root-less wireshark and add mininet |
| 147 | echo "Enabling wireshark group" |
| 148 | echo "wireshark-common wireshark-common/install-setuid boolean true" | sudo debconf-set-selections |
| 149 | sudo dpkg-reconfigure -f noninteractive wireshark-common |
| 150 | sudo usermod -a -G wireshark mininet |
alshabib | d4da55d | 2014-11-19 19:31:30 -0800 | [diff] [blame] | 151 | sudo usermod -a -G wireshark tutorial1 |
| 152 | |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 153 | |
| 154 | echo "Installing VirtualBox Guest Additions" |
| 155 | sudo apt-get install -y virtualbox-guest-x11 |
| 156 | |
| 157 | # ------------- Zero Unused Blocks ------------- |
| 158 | #TODO investigate zerofree |
| 159 | echo "Zeroing unused blocks" |
| 160 | sync |
| 161 | dd if=/dev/zero of=tmp-zeros |
| 162 | sync |
| 163 | rm tmp-zeros |
| 164 | sync |