blob: 833e538669fee3c9c84f892992eba14ef4048465 [file] [log] [blame]
#!/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
sudo lxc-create --name onos1 -t download -- --dist ubuntu --release utopic --arch amd64
#sudo sh -c "echo lxc.network.ipv4=10.0.3.11 >> /var/lib/lxc/onos1/config"
#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 sh -c "cat /var/lib/lxc/onos1/rootfs/etc/network/interfaces"
sudo lxc-start --name onos1 --daemon
sudo lxc-ls --fancy
sleep 10
sudo lxc-ls --fancy
sudo lxc-attach --name onos1 -- ip a
sudo lxc-attach --name onos1 -- ping -c3 www.google.com
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-jdk
#sudo lxc-attach --name onos1 -- apt-get install software-properties-common -y
#sudo lxc-attach --name onos1 -- add-apt-repository ppa:webupd8team/java -y
#sudo lxc-attach --name onos1 -- apt-get update
#sudo lxc-attach --name onos1 -- apt-get install oracle-java8-installer oracle-java8-set-default -y
sudo lxc-stop --name onos1