blob: 86ddb38a63b2bce1376690f752bf89d72f487499 [file] [log] [blame]
Jonathan Hart53433b52015-03-26 17:23:34 -07001#!/bin/bash
2# vm-setup.sh
3#
4# This script sets up the VM ready to run ONOS and tutorials, including installing an LXC cluster
5# for ONOS to run in.
6
7sudo apt-get update
8
Jonathan Hart5815d9e2015-03-26 17:38:24 -07009# TODO erlang, quagga, wireshark
Jonathan Hart047c9032015-03-26 20:18:40 -070010#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
Jonathan Hartcaba1612015-03-27 08:22:16 -070011sudo apt-get install -y git openjdk-8-jdk maven unzip curl wget lxc
12#sudo apt-get install -y git wget curl lxc
Jonathan Hart53433b52015-03-26 17:23:34 -070013sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
14sudo update-alternatives --set javac /usr/lib/jvm/java-8-openjdk-amd64/bin/javac
15
Jonathan Hartc397cf22015-03-27 08:04:08 -070016# -------------- Setup keys -------------------
17
18mkdir -p ~/.ssh
19ssh-keygen -t rsa -P "" -f .ssh/id_rsa
20#cp .ssh/id_rsa.pub .ssh/authorized_keys
21
22# -------------- Setup 3-node LXC cluster ----------------
23
Jonathan Hart2f4271d2015-03-26 18:40:57 -070024sudo lxc-create --name onos1 -t download -- --dist ubuntu --release utopic --arch amd64
Jonathan Hart53433b52015-03-26 17:23:34 -070025
Jonathan Hartc397cf22015-03-27 08:04:08 -070026sudo sh -c "echo lxc.start.auto=1 >> /var/lib/lxc/onos1/config"
Jonathan Hart53433b52015-03-26 17:23:34 -070027
Jonathan Hart4bb029f2015-03-26 22:45:15 -070028sudo sh -c "sed -i s/dhcp/static/ /var/lib/lxc/onos1/rootfs/etc/network/interfaces"
29sudo sh -c "cat << EOF >> /var/lib/lxc/onos1/rootfs/etc/network/interfaces
30 address 10.0.3.11
31 netmask 255.255.255.0
32 gateway 10.0.3.1
33 dns-nameservers 10.0.3.1
34EOF"
35
Jonathan Hart53433b52015-03-26 17:23:34 -070036sudo lxc-start --name onos1 --daemon
Jonathan Hartc397cf22015-03-27 08:04:08 -070037
Jonathan Harta897f4e2015-03-26 22:31:41 -070038sudo lxc-ls --fancy
Jonathan Hartc397cf22015-03-27 08:04:08 -070039sleep 5
Jonathan Harta897f4e2015-03-26 22:31:41 -070040sudo lxc-ls --fancy
Jonathan Hart17a00392015-03-26 22:24:25 -070041sudo lxc-attach --name onos1 -- ip a
Jonathan Hartc397cf22015-03-27 08:04:08 -070042
Jonathan Hart53433b52015-03-26 17:23:34 -070043sudo lxc-attach --name onos1 -- useradd -m sdn -s /bin/bash
44sudo lxc-attach --name onos1 -- /bin/bash -c "echo sdn:rocks | chpasswd"
45sudo lxc-attach --name onos1 -- /bin/bash -c "echo \"sdn ALL=(ALL) NOPASSWD:ALL\" > /etc/sudoers.d/sdn"
46sudo lxc-attach --name onos1 -- apt-get update
Jonathan Hartc397cf22015-03-27 08:04:08 -070047sudo lxc-attach --name onos1 -- apt-get install -y openssh-server openjdk-8-jre-headless
48
Jonathan Hart53433b52015-03-26 17:23:34 -070049sudo lxc-stop --name onos1
Jonathan Hartc397cf22015-03-27 08:04:08 -070050
Jonathan Hartcaba1612015-03-27 08:22:16 -070051sudo mkdir -p /var/lib/lxc/onos1/rootfs/home/sdn/.ssh
Jonathan Hartc397cf22015-03-27 08:04:08 -070052sudo cp ~/.ssh/id_rsa.pub /var/lib/lxc/onos1/rootfs/home/sdn/.ssh/authorized_keys
53sudo chmod 666 /var/lib/lxc/onos1/rootfs/home/sdn/.ssh/authorized_keys
54
55sudo lxc-clone onos1 onos2
Jonathan Hartcaba1612015-03-27 08:22:16 -070056sudo sh -c "sed -i s/10.0.3.11/10.0.3.12/ /var/lib/lxc/onos2/rootfs/etc/network/interfaces"
Jonathan Hartc397cf22015-03-27 08:04:08 -070057
58sudo lxc-clone onos1 onos3
Jonathan Hartcaba1612015-03-27 08:22:16 -070059sudo sh -c "sed -i s/10.0.3.11/10.0.3.13/ /var/lib/lxc/onos3/rootfs/etc/network/interfaces"
Jonathan Hartc397cf22015-03-27 08:04:08 -070060
61sudo lxc-start --name onos1
62sudo lxc-start --name onos2
63sudo lxc-start --name onos3
64
65sleep 5
66
67sudo lxc-ls --fancy
68
69# -------------- Install ONOS ----------------
70
71USER=mininet
72USER_HOME=/home/${USER}
73
Jonathan Hartfc7c63f2015-03-27 09:32:27 -070074echo "hello"
Jonathan Hartcaba1612015-03-27 08:22:16 -070075sudo su - ${USER}
Jonathan Hartfc7c63f2015-03-27 09:32:27 -070076echo "chusr"
77echo `whoami`
Jonathan Hartcaba1612015-03-27 08:22:16 -070078
Jonathan Hartc397cf22015-03-27 08:04:08 -070079cd ~
80git clone https://gerrit.onosproject.org/onos
81cd onos && git checkout 1.1.0 && cd -
82
Jonathan Hartcaba1612015-03-27 08:22:16 -070083echo ". ~/onos/tools/dev/bash_profile" >> ~/.bashrc
84echo "export ONOS_ROOT=${USER_HOME}/onos" >> ~/.bashrc
85
86exit
87sudo su - ${USER}
88
Jonathan Hartc397cf22015-03-27 08:04:08 -070089echo $JAVA_HOME
90export JAVA_HOME=""
91cd $ONOS_ROOT && mvn clean install && mvn dependency:go-offline && cd -
92
93cat << EOF >> onos/tools/test/cells/tutorial
94export ONOS_NIC=10.0.3.*
95export OC1="10.0.3.11"
96export OC1="10.0.3.12"
97export OC1="10.0.3.13"
98export OCI="${OC1}"
99export ONOS_FEATURES="webconsole,onos-rest,onos-gui,onos-api,onos-core,onos-cli,onos-openflow"
100export ONOS_USER="sdn"
101EOF
102
103cell tutorial
104
105onos-package
106onos-group install -f
107onos-wait-for-start $OC1
108onos-wait-for-start $OC2
109onos-wait-for-start $OC3
110
111sleep 20
Jonathan Hartfc7c63f2015-03-27 09:32:27 -0700112onos 1 "nodes"
113
114exit