| #!/bin/bash |
| # vm-setup.sh |
| # |
| # This script sets up the VM ready to run ONOS and tutorials, including installing an LXC cluster |
| # for ONOS to run in. |
| |
| sudo apt-get update |
| |
| # TODO erlang, quagga, wireshark |
| #sudo apt-get install -y git openjdk-8-jdk maven unzip curl make gcc wget autoconf openssl libssl0.9.8 libssl-dev libncurses5 libncurses5-dev lxc |
| sudo apt-get install -y git openjdk-8-jdk maven unzip curl wget lxc |
| #sudo apt-get install -y git wget curl lxc |
| sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java |
| sudo update-alternatives --set javac /usr/lib/jvm/java-8-openjdk-amd64/bin/javac |
| |
| # -------------- Setup keys ------------------- |
| |
| mkdir -p ~/.ssh |
| ssh-keygen -t rsa -P "" -f .ssh/id_rsa |
| #cp .ssh/id_rsa.pub .ssh/authorized_keys |
| |
| # -------------- 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 -- apt-get update |
| sudo lxc-attach --name onos1 -- apt-get install -y openssh-server openjdk-8-jre-headless |
| |
| sudo lxc-stop --name onos1 |
| |
| 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 chmod 666 /var/lib/lxc/onos1/rootfs/home/sdn/.ssh/authorized_keys |
| |
| 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 5 |
| |
| sudo lxc-ls --fancy |
| |
| # -------------- Install ONOS ---------------- |
| |
| USER=mininet |
| USER_HOME=/home/${USER} |
| |
| echo "hello" |
| sudo su - ${USER} |
| echo "chusr" |
| echo `whoami` |
| |
| cd ~ |
| git clone https://gerrit.onosproject.org/onos |
| cd onos && git checkout 1.1.0 && cd - |
| |
| echo ". ~/onos/tools/dev/bash_profile" >> ~/.bashrc |
| echo "export ONOS_ROOT=${USER_HOME}/onos" >> ~/.bashrc |
| |
| exit |
| sudo su - ${USER} |
| |
| echo $JAVA_HOME |
| export JAVA_HOME="" |
| cd $ONOS_ROOT && mvn clean install && mvn dependency:go-offline && cd - |
| |
| cat << EOF >> onos/tools/test/cells/tutorial |
| export ONOS_NIC=10.0.3.* |
| export OC1="10.0.3.11" |
| export OC1="10.0.3.12" |
| export OC1="10.0.3.13" |
| export OCI="${OC1}" |
| export ONOS_FEATURES="webconsole,onos-rest,onos-gui,onos-api,onos-core,onos-cli,onos-openflow" |
| export ONOS_USER="sdn" |
| EOF |
| |
| cell tutorial |
| |
| onos-package |
| onos-group install -f |
| onos-wait-for-start $OC1 |
| onos-wait-for-start $OC2 |
| onos-wait-for-start $OC3 |
| |
| sleep 20 |
| onos 1 "nodes" |
| |
| exit |