blob: 260d52f9b22adf019f0d1b99ce633bb173f7bfa0 [file] [log] [blame]
#!/bin/bash
# vm-setup.sh
#
# This script installs ONOS dependencies and installs a desktop environment on a Miniet VM.
ONOS_USER=mininet
ONOS_USER_HOME=/home/${ONOS_USER}
ECLIPSE_URL=http://download.eclipse.org/technology/epp/downloads/release/luna/R/eclipse-java-luna-R-linux-gtk-x86_64.tar.gz
sudo apt-get update
=======
oracle-java8-installer shared/accepted-oracle-license-v1-1 select true
oracle-java8-installer shared/accepted-oracle-license-v1-1 seen true
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
sudo apt-get install -y git maven unzip curl wget lxc virtualbox-guest-utils wireshark \
quagga erlang make gcc autoconf openssl libssl0.9.8 libssl-dev libncurses5 libncurses5-dev \
oracle-java8-installer oracle-java8-set-default
# -------------- Setup keys -------------------
mkdir -p ~/.ssh
ssh-keygen -t rsa -P "" -f .ssh/id_rsa
# -------------- Setup 3-node LXC cluster ----------------
sudo lxc-create --name onos1 -t download -- --dist ubuntu --release utopic --arch amd64
sudo sh -c "echo lxc.start.auto=1 >> /var/lib/lxc/onos1/config"
sudo sh -c "sed -i s/dhcp/static/ /var/lib/lxc/onos1/rootfs/etc/network/interfaces"
sudo sh -c "cat << EOF >> /var/lib/lxc/onos1/rootfs/etc/network/interfaces
address 10.0.3.11
netmask 255.255.255.0
gateway 10.0.3.1
dns-nameservers 10.0.3.1
EOF"
sudo lxc-start --name onos1 --daemon
sudo lxc-ls --fancy
sleep 5
sudo lxc-ls --fancy
sudo lxc-attach --name onos1 -- ip a
sudo lxc-attach --name onos1 -- useradd -m sdn -s /bin/bash
sudo lxc-attach --name onos1 -- /bin/bash -c "echo sdn:rocks | chpasswd"
sudo lxc-attach --name onos1 -- /bin/bash -c "echo \"sdn ALL=(ALL) NOPASSWD:ALL\" > /etc/sudoers.d/sdn"
sudo lxc-attach --name onos1 -- oracle-java8-installer shared/accepted-oracle-license-v1-1 select true
sudo lxc-attach --name onos1 -- oracle-java8-installer shared/accepted-oracle-license-v1-1 seen true
sudo lxc-attach --name onos1 -- apt-get update
sudo lxc-attach --name onos1 -- apt-get install -y openssh-server oracle-java8-installer oracle-java8-set-default
sudo mkdir -p /var/lib/lxc/onos1/rootfs/home/sdn/.ssh
sudo cp ~/.ssh/id_rsa.pub /var/lib/lxc/onos1/rootfs/home/sdn/.ssh/authorized_keys
sudo lxc-attach --name onos1 -- chown sdn:sdn /home/sdn/.ssh/authorized_keys
sudo lxc-attach --name onos1 -- chmod 600 /home/sdn/.ssh/authorized_keys
sudo lxc-attach --name onos1 -- apt-get clean
sudo lxc-stop --name onos1
# Clone the first node to create two more nodes
sudo lxc-clone onos1 onos2
sudo sh -c "sed -i s/10.0.3.11/10.0.3.12/ /var/lib/lxc/onos2/rootfs/etc/network/interfaces"
sudo lxc-clone onos1 onos3
sudo sh -c "sed -i s/10.0.3.11/10.0.3.13/ /var/lib/lxc/onos3/rootfs/etc/network/interfaces"
sudo lxc-start --name onos1
sudo lxc-start --name onos2
sudo lxc-start --name onos3
sleep 10
>>>>>>> Stashed changes
# ------------- Install ONOS Dependencies -------------
oracle-java8-installer shared/accepted-oracle-license-v1-1 select true
oracle-java8-installer shared/accepted-oracle-license-v1-1 seen true
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
sudo apt-get install -y oracle-java8-installer oracle-java8-set-default
sudo apt-get install -y maven
# CLI dependencies
sudo apt-get install -y python-flask python-cmd2 python-pyparsing
# -------------- Setup Desktop ----------------
sudo apt-get install -y xorg lxde
#TODO: add backgrounds folder
#TODO: change background
# Remove wallpaper, change background color, and disable screensaver
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 '/screensaver/d' /etc/xdg/lxsession/LXDE/autostart
DESKTOP=${ONOS_USER_HOME}/Desktop
mkdir -p ${DESKTOP}
cat > ${DESKTOP}/Eclipse << EOF
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=Eclipse
Name[en_US]=Eclipse
Icon=/opt/eclipse/icon.xpm
Exec=/usr/bin/eclipse
Comment[en_US]=
EOF
cat > ${DESKTOP}/Terminal << EOF
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=Terminal
Name[en_US]=Terminal
Icon=konsole
Exec=/usr/bin/x-terminal-emulator
Comment[en_US]=
EOF
cat > ${DESKTOP}/Gerrit << EOF
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=ONOS Gerrit
Name[en_US]=ONOS Gerrit
Icon=internet-web-browser
Exec=/usr/bin/chromium-browser http://gerrit.onlab.us
Comment[en_US]=
EOF
cat > ${DESKTOP}/Docs << EOF
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=ONOS Docs
Name[en_US]=ONOS Docs
Icon=internet-web-browser
Exec=/usr/bin/chromium-browser http://docs.onos.onlab.us
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
sudo apt-get install -y git-review
wget -c -N -O /tmp/eclipse.tar.gz ${ECLIPSE_URL}
tar xzf /tmp/eclipse.tar.gz
sudo mv eclipse /opt
sudo ln -s /opt/eclipse/eclipse /usr/bin/eclipse
# ------------ Change username and hostname ---------------
echo 'mininet:onos' | sudo chpasswd
sudo mv /home/mininet /home/onos
sudo sed -i 's/mininet/onos/g' /etc/group /etc/gshadow /etc/hosts /etc/hostname /etc/passwd /etc/shadow /etc/sudoers