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