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 | |
alshabib | cf82ac7 | 2014-12-01 09:42:32 -0800 | [diff] [blame^] | 17 | #--------------- Clean Karaf Run -------------- |
| 18 | |
| 19 | echo "sudo service onos restart" >> ~/.bashrc |
| 20 | |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 21 | # -------------- Install Karaf ---------------- |
| 22 | |
| 23 | mkdir Downloads |
| 24 | cd Downloads |
alshabib | eeb8130 | 2014-11-18 14:12:22 -0800 | [diff] [blame] | 25 | 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] | 26 | cd - |
| 27 | |
alshabib | 71ec25a | 2014-11-18 18:59:46 -0800 | [diff] [blame] | 28 | # -------------- Setup Wireshark dissector ---- |
| 29 | |
| 30 | wget -O openflow.lua "https://gerrit.onosproject.org/gitweb?p=ONOS-VM.git;a=blob_plain;hb=refs/heads/onos-tutorial;f=openflow.lua" |
| 31 | mkdir -p .wireshark/plugins |
| 32 | mv openflow.lua .wireshark/plugins |
| 33 | |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 34 | # -------------- Setup Desktop ---------------- |
| 35 | |
| 36 | sudo apt-get install -y xorg lxde |
| 37 | |
| 38 | #TODO: add backgrounds folder |
alshabib | da71cc9 | 2014-11-18 16:39:41 -0800 | [diff] [blame] | 39 | sudo mkdir -p /usr/share/backgrounds |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 40 | #TODO: change background |
| 41 | # Remove wallpaper, change background color |
| 42 | sudo sed -i 's/wallpaper_mode=1/wallpaper_mode=0/g' /usr/share/lxde/pcmanfm/LXDE.conf |
| 43 | sudo sed -i 's/desktop_bg=#000000/desktop_bg=#104187/g' /usr/share/lxde/pcmanfm/LXDE.conf |
| 44 | |
| 45 | # Automatically start LXDE on login |
| 46 | echo '[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx' >> ~/.bashrc |
| 47 | |
| 48 | # Automatically log into the VM |
| 49 | #sudo sed -i 's/exec /sbin/getty -8 38400 tty1//g' /etc/init/tty1.conf |
| 50 | #sudo sed -i '$ d' /etc/init/tty1.conf |
| 51 | #echo 'exec /bin/login -f bob < /dev/tty1 > /dev/tty1 2>&1' | sudo tee -a /etc/init/tty1.conf |
| 52 | |
| 53 | # Disable screensaver |
| 54 | sudo sed -i '/screensaver/d' /etc/xdg/lxsession/LXDE/autostart |
| 55 | cat > ${USER_HOME}/.xsessionrc << EOF |
| 56 | # disable screensaver |
| 57 | xset s off |
| 58 | # disable dpms (standby) |
| 59 | xset -dpms |
| 60 | EOF |
| 61 | |
| 62 | # Change LXTerminal default colors |
| 63 | #sudo sed -i 's/bgcolor=#000000000000/bgcolor=#ffffffffffff/g' ${USER_HOME}/.config/lxterminal/lxterminal.conf |
| 64 | #sudo sed -i 's/fgcolor=#aaaaaaaaaaaa/fgcolor=#000000000000/g' ${USER_HOME}/.config/lxterminal/lxterminal.conf |
| 65 | sudo sed -i 's/bgcolor=#000000000000/bgcolor=#ffffffffffff/g' /usr/share/lxterminal/lxterminal.conf |
| 66 | sudo sed -i 's/fgcolor=#aaaaaaaaaaaa/fgcolor=#000000000000/g' /usr/share/lxterminal/lxterminal.conf |
| 67 | |
| 68 | DESKTOP=${USER_HOME}/Desktop |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 69 | |
| 70 | mkdir -p ${DESKTOP} |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 71 | |
| 72 | cat > ${DESKTOP}/ONOS << EOF |
| 73 | [Desktop Entry] |
| 74 | Encoding=UTF-8 |
| 75 | Type=Application |
alshabib | f86bfb3 | 2014-11-17 22:30:26 -0800 | [diff] [blame] | 76 | Name=ONOS |
| 77 | Name[en_US]=ONOS |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 78 | Icon=konsole |
alshabib | 502ad14 | 2014-11-19 21:58:23 -0800 | [diff] [blame] | 79 | 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] | 80 | Comment[en_US]= |
| 81 | EOF |
| 82 | |
| 83 | cat > ${DESKTOP}/Mininet << EOF |
| 84 | [Desktop Entry] |
| 85 | Encoding=UTF-8 |
| 86 | Type=Application |
alshabib | f86bfb3 | 2014-11-17 22:30:26 -0800 | [diff] [blame] | 87 | Name=Mininet |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 88 | Name[en_US]=Mininet |
| 89 | Icon=konsole |
alshabib | 502ad14 | 2014-11-19 21:58:23 -0800 | [diff] [blame] | 90 | 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] | 91 | Comment[en_US]= |
| 92 | EOF |
| 93 | |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 94 | cat > ${DESKTOP}/Tutorial << EOF |
| 95 | [Desktop Entry] |
| 96 | Encoding=UTF-8 |
| 97 | Type=Application |
alshabib | f86bfb3 | 2014-11-17 22:30:26 -0800 | [diff] [blame] | 98 | Name=ONOS Tutorial |
| 99 | Name[en_US]=ONOS Tutorial |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 100 | Icon=internet-web-browser |
alshabib | f86bfb3 | 2014-11-17 22:30:26 -0800 | [diff] [blame] | 101 | 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] | 102 | Comment[en_US]= |
| 103 | EOF |
| 104 | |
alshabib | bf2db60 | 2014-11-19 18:13:49 -0800 | [diff] [blame] | 105 | cat > ${DESKTOP}/GUI << EOF |
| 106 | [Desktop Entry] |
| 107 | Encoding=UTF-8 |
| 108 | Type=Application |
| 109 | Name=ONOS GUI |
| 110 | Name[en_US]=ONOS GUI |
| 111 | Icon=internet-web-browser |
| 112 | Exec=/usr/bin/chromium-browser http://localhost:8181/onos/ui/index2.html#topo |
| 113 | Comment[en_US]= |
| 114 | EOF |
| 115 | |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 116 | cat > ${DESKTOP}/Wireshark << EOF |
| 117 | [Desktop Entry] |
| 118 | Encoding=UTF-8 |
| 119 | Type=Application |
| 120 | Name=Wireshark |
| 121 | Name[en_US]=Wireshark |
| 122 | Icon=wireshark |
| 123 | Exec=/usr/bin/wireshark |
| 124 | Comment[en_US]= |
| 125 | EOF |
| 126 | |
| 127 | # ------------- Install Other Tools ------------- |
| 128 | sudo apt-get install -y wireshark |
| 129 | # Enable root-less wireshark and add mininet |
| 130 | echo "Enabling wireshark group" |
| 131 | echo "wireshark-common wireshark-common/install-setuid boolean true" | sudo debconf-set-selections |
| 132 | sudo dpkg-reconfigure -f noninteractive wireshark-common |
| 133 | sudo usermod -a -G wireshark mininet |
alshabib | d4da55d | 2014-11-19 19:31:30 -0800 | [diff] [blame] | 134 | sudo usermod -a -G wireshark tutorial1 |
| 135 | |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 136 | |
| 137 | echo "Installing VirtualBox Guest Additions" |
| 138 | sudo apt-get install -y virtualbox-guest-x11 |
| 139 | |
| 140 | # ------------- Zero Unused Blocks ------------- |
| 141 | #TODO investigate zerofree |
| 142 | echo "Zeroing unused blocks" |
| 143 | sync |
| 144 | dd if=/dev/zero of=tmp-zeros |
| 145 | sync |
| 146 | rm tmp-zeros |
| 147 | sync |