blob: 9c01ae0cd1a55e5e9313f945e4c0f753fd813063 [file] [log] [blame]
#!/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 Desktop ----------------
sudo apt-get install -y xorg lxde
#TODO: add backgrounds folder
sudo mkdir /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
# 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
# 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
OFFLINE="${DESKTOP}/Offline Exercises"
mkdir -p ${DESKTOP}
mkdir -p "${OFFLINE}"
cat > ${DESKTOP}/ONOS << EOF
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=ONOS
Name[en_US]=ONOS
Icon=konsole
Exec=/usr/bin/xterm -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/xterm -e 'sudo mn --custom ~/onos-next/tools/test/topos/tower.py --topo tower --controller remote,${1:-192.168.2.1} --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}/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
# ------------- 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
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