| #!/bin/bash |
| # vm-setup.sh |
| # |
| # This script installs ONOS dependencies and installs a desktop environment on a Miniet VM. |
| |
| |
| export CURRENT_USER=tutorial1 |
| export USER_HOME=/home/${CURRENT_USER} |
| |
| |
| # -------------- Setup keys ------------------- |
| |
| mkdir -p ~/.ssh |
| ssh-keygen -t dsa -P "" -f .ssh/id_dsa |
| cp .ssh/id_dsa.pub .ssh/authorized_keys |
| |
| # -------------- Install Karaf ---------------- |
| |
| mkdir Downloads |
| cd Downloads |
| wget http://apache.osuosl.org/karaf/3.0.2/apache-karaf-3.0.2.zip |
| cd - |
| |
| # -------------- Setup Wireshark dissector ---- |
| |
| wget -O openflow.lua "https://gerrit.onosproject.org/gitweb?p=onos-vm.git;a=blob_plain;hb=refs/heads/onos-tutorial;f=openflow.lua" |
| mkdir -p .wireshark/plugins |
| mv openflow.lua .wireshark/plugins |
| |
| |
| |
| # -------------- Setup Desktop ---------------- |
| |
| sudo apt-get install -y xorg lxde systemd-shim |
| |
| #TODO: add backgrounds folder |
| sudo mkdir -p /usr/share/backgrounds |
| #TODO: change background |
| # Remove wallpaper, change background color |
| sudo sed -i 's/wallpaper_mode=1/wallpaper_mode=0/g' /usr/share/lxde/pcmanfm/LXDE.conf |
| sudo sed -i 's/desktop_bg=#000000/desktop_bg=#104187/g' /usr/share/lxde/pcmanfm/LXDE.conf |
| |
| sudo sed -i 's/lang=1/lang=0/g' /etc/lxdm/default.conf |
| sudo sed -i 's/bottom_pane=1/bottom_pane=0/g' /etc/lxdm/default.conf |
| sudo sed -i 's/disable=0/disable=1/g' /etc/lxdm/default.conf |
| |
| # Allow VM to be rebooted from GUI |
| echo "session required pam_systemd.so" | sudo tee --append /etc/pam.d/lxdm |
| |
| wget -O onos.png "https://gerrit.onosproject.org/gitweb?p=onos-vm.git;a=blob_plain;hb=refs/heads/onos-tutorial;f=onos.png" |
| sudo cp onos.png /usr/share/backgrounds/default.png |
| |
| # Automatically start LXDE on login |
| echo '[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx' >> ~/.bashrc |
| |
| # Automatically log into the VM |
| #sudo sed -i 's/exec /sbin/getty -8 38400 tty1//g' /etc/init/tty1.conf |
| #sudo sed -i '$ d' /etc/init/tty1.conf |
| #echo 'exec /bin/login -f bob < /dev/tty1 > /dev/tty1 2>&1' | sudo tee -a /etc/init/tty1.conf |
| |
| echo "sudo service onos start > /dev/null 2>&1" >> ~/.profile |
| |
| # Disable screensaver |
| sudo sed -i '/screensaver/d' /etc/xdg/lxsession/LXDE/autostart |
| cat > ${USER_HOME}/.xsessionrc << EOF |
| # disable screensaver |
| xset s off |
| # disable dpms (standby) |
| xset -dpms |
| EOF |
| |
| # Change LXTerminal default colors |
| #sudo sed -i 's/bgcolor=#000000000000/bgcolor=#ffffffffffff/g' ${USER_HOME}/.config/lxterminal/lxterminal.conf |
| #sudo sed -i 's/fgcolor=#aaaaaaaaaaaa/fgcolor=#000000000000/g' ${USER_HOME}/.config/lxterminal/lxterminal.conf |
| sudo sed -i 's/bgcolor=#000000000000/bgcolor=#ffffffffffff/g' /usr/share/lxterminal/lxterminal.conf |
| sudo sed -i 's/fgcolor=#aaaaaaaaaaaa/fgcolor=#000000000000/g' /usr/share/lxterminal/lxterminal.conf |
| |
| DESKTOP=${USER_HOME}/Desktop |
| |
| mkdir -p ${DESKTOP} |
| |
| cat > ${DESKTOP}/ONOS << EOF |
| [Desktop Entry] |
| Encoding=UTF-8 |
| Type=Application |
| Name=ONOS |
| Name[en_US]=ONOS |
| Icon=konsole |
| Exec=/usr/bin/lxterminal -e '/opt/onos/apache-karaf-3.0.2/bin/client -u karaf' |
| Comment[en_US]= |
| EOF |
| |
| cat > ${DESKTOP}/Mininet << EOF |
| [Desktop Entry] |
| Encoding=UTF-8 |
| Type=Application |
| Name=Mininet |
| Name[en_US]=Mininet |
| Icon=konsole |
| Exec=/usr/bin/lxterminal -e 'sudo mn --custom /home/tutorial1/onos/tools/test/topos/tower.py --topo tower --controller remote --mac' |
| Comment[en_US]= |
| EOF |
| |
| cat > ${DESKTOP}/Tutorial << EOF |
| [Desktop Entry] |
| Encoding=UTF-8 |
| Type=Application |
| Name=ONOS Tutorial |
| Name[en_US]=ONOS Tutorial |
| Icon=internet-web-browser |
| Exec=/usr/bin/chromium-browser https://wiki.onosproject.org/display/ONOS/Basic+ONOS+Tutorial |
| Comment[en_US]= |
| EOF |
| |
| cat > ${DESKTOP}/GUI << EOF |
| [Desktop Entry] |
| Encoding=UTF-8 |
| Type=Application |
| Name=ONOS GUI |
| Name[en_US]=ONOS GUI |
| Icon=internet-web-browser |
| Exec=/usr/bin/chromium-browser http://localhost:8181/onos/ui/index.html#topo |
| Comment[en_US]= |
| EOF |
| |
| cat > ${DESKTOP}/Wireshark << EOF |
| [Desktop Entry] |
| Encoding=UTF-8 |
| Type=Application |
| Name=Wireshark |
| Name[en_US]=Wireshark |
| Icon=wireshark |
| Exec=/usr/bin/wireshark |
| Comment[en_US]= |
| EOF |
| |
| cat > ${DESKTOP}/Reset << EOF |
| [Desktop Entry] |
| Encoding=UTF-8 |
| Type=Application |
| Name=Reset |
| Name[en_US]=Reset |
| Icon=konsole |
| Exec=/usr/bin/lxterminal -t 'Resetting; please wait' -e 'sudo service onos restart' |
| Comment[en_US]= |
| EOF |
| |
| # ------------- Install Other Tools ------------- |
| sudo apt-get install -y wireshark |
| # Enable root-less wireshark and add mininet |
| echo "Enabling wireshark group" |
| echo "wireshark-common wireshark-common/install-setuid boolean true" | sudo debconf-set-selections |
| sudo dpkg-reconfigure -f noninteractive wireshark-common |
| sudo usermod -a -G wireshark mininet |
| sudo usermod -a -G wireshark tutorial1 |
| |
| |
| echo "Installing VirtualBox Guest Additions" |
| sudo apt-get install -y virtualbox-guest-x11 |
| |
| # ------------- Zero Unused Blocks ------------- |
| #TODO investigate zerofree |
| echo "Zeroing unused blocks" |
| sync |
| dd if=/dev/zero of=tmp-zeros |
| sync |
| rm tmp-zeros |
| sync |