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 | |
| 24 | # -------------- Setup Desktop ---------------- |
| 25 | |
| 26 | sudo apt-get install -y xorg lxde |
| 27 | |
| 28 | #TODO: add backgrounds folder |
| 29 | sudo mkdir /usr/share/backgrounds |
| 30 | #TODO: change background |
| 31 | # Remove wallpaper, change background color |
| 32 | sudo sed -i 's/wallpaper_mode=1/wallpaper_mode=0/g' /usr/share/lxde/pcmanfm/LXDE.conf |
| 33 | sudo sed -i 's/desktop_bg=#000000/desktop_bg=#104187/g' /usr/share/lxde/pcmanfm/LXDE.conf |
| 34 | |
| 35 | # Automatically start LXDE on login |
| 36 | echo '[[ -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 |
| 44 | sudo sed -i '/screensaver/d' /etc/xdg/lxsession/LXDE/autostart |
| 45 | cat > ${USER_HOME}/.xsessionrc << EOF |
| 46 | # disable screensaver |
| 47 | xset s off |
| 48 | # disable dpms (standby) |
| 49 | xset -dpms |
| 50 | EOF |
| 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 |
| 55 | sudo sed -i 's/bgcolor=#000000000000/bgcolor=#ffffffffffff/g' /usr/share/lxterminal/lxterminal.conf |
| 56 | sudo sed -i 's/fgcolor=#aaaaaaaaaaaa/fgcolor=#000000000000/g' /usr/share/lxterminal/lxterminal.conf |
| 57 | |
| 58 | DESKTOP=${USER_HOME}/Desktop |
| 59 | OFFLINE="${DESKTOP}/Offline Exercises" |
| 60 | |
| 61 | mkdir -p ${DESKTOP} |
| 62 | mkdir -p "${OFFLINE}" |
| 63 | |
| 64 | cat > ${DESKTOP}/ONOS << EOF |
| 65 | [Desktop Entry] |
| 66 | Encoding=UTF-8 |
| 67 | Type=Application |
alshabib | f86bfb3 | 2014-11-17 22:30:26 -0800 | [diff] [blame] | 68 | Name=ONOS |
| 69 | Name[en_US]=ONOS |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 70 | Icon=konsole |
| 71 | Exec=/usr/bin/xterm -e '/opt/onos/apache-karaf-3.0.2/bin/client -u karaf' |
| 72 | Comment[en_US]= |
| 73 | EOF |
| 74 | |
| 75 | cat > ${DESKTOP}/Mininet << EOF |
| 76 | [Desktop Entry] |
| 77 | Encoding=UTF-8 |
| 78 | Type=Application |
alshabib | f86bfb3 | 2014-11-17 22:30:26 -0800 | [diff] [blame] | 79 | Name=Mininet |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 80 | Name[en_US]=Mininet |
| 81 | Icon=konsole |
alshabib | f86bfb3 | 2014-11-17 22:30:26 -0800 | [diff] [blame] | 82 | Exec=/usr/bin/xterm -e 'sudo mn --custom ~/onos-next/tools/test/topos/tower.py --topo tower --controller remote,${1:-192.168.2.1} --mac' |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 83 | Comment[en_US]= |
| 84 | EOF |
| 85 | |
| 86 | |
| 87 | |
| 88 | cat > ${DESKTOP}/Tutorial << EOF |
| 89 | [Desktop Entry] |
| 90 | Encoding=UTF-8 |
| 91 | Type=Application |
alshabib | f86bfb3 | 2014-11-17 22:30:26 -0800 | [diff] [blame] | 92 | Name=ONOS Tutorial |
| 93 | Name[en_US]=ONOS Tutorial |
alshabib | 3881a14 | 2014-11-17 15:04:35 -0800 | [diff] [blame] | 94 | Icon=internet-web-browser |
alshabib | f86bfb3 | 2014-11-17 22:30:26 -0800 | [diff] [blame] | 95 | 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] | 96 | Comment[en_US]= |
| 97 | EOF |
| 98 | |
| 99 | cat > ${DESKTOP}/Wireshark << EOF |
| 100 | [Desktop Entry] |
| 101 | Encoding=UTF-8 |
| 102 | Type=Application |
| 103 | Name=Wireshark |
| 104 | Name[en_US]=Wireshark |
| 105 | Icon=wireshark |
| 106 | Exec=/usr/bin/wireshark |
| 107 | Comment[en_US]= |
| 108 | EOF |
| 109 | |
| 110 | # ------------- Install Other Tools ------------- |
| 111 | sudo apt-get install -y wireshark |
| 112 | # Enable root-less wireshark and add mininet |
| 113 | echo "Enabling wireshark group" |
| 114 | echo "wireshark-common wireshark-common/install-setuid boolean true" | sudo debconf-set-selections |
| 115 | sudo dpkg-reconfigure -f noninteractive wireshark-common |
| 116 | sudo usermod -a -G wireshark mininet |
| 117 | |
| 118 | echo "Installing VirtualBox Guest Additions" |
| 119 | sudo apt-get install -y virtualbox-guest-x11 |
| 120 | |
| 121 | # ------------- Zero Unused Blocks ------------- |
| 122 | #TODO investigate zerofree |
| 123 | echo "Zeroing unused blocks" |
| 124 | sync |
| 125 | dd if=/dev/zero of=tmp-zeros |
| 126 | sync |
| 127 | rm tmp-zeros |
| 128 | sync |