Jonathan Hart | 53433b5 | 2015-03-26 17:23:34 -0700 | [diff] [blame] | 1 | #!/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 | |
| 7 | sudo apt-get update |
| 8 | |
Jonathan Hart | 5815d9e | 2015-03-26 17:38:24 -0700 | [diff] [blame] | 9 | # TODO erlang, quagga, wireshark |
Jonathan Hart | 047c903 | 2015-03-26 20:18:40 -0700 | [diff] [blame] | 10 | #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 Hart | caba161 | 2015-03-27 08:22:16 -0700 | [diff] [blame] | 11 | sudo apt-get install -y git openjdk-8-jdk maven unzip curl wget lxc |
| 12 | #sudo apt-get install -y git wget curl lxc |
Jonathan Hart | 53433b5 | 2015-03-26 17:23:34 -0700 | [diff] [blame] | 13 | sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java |
| 14 | sudo update-alternatives --set javac /usr/lib/jvm/java-8-openjdk-amd64/bin/javac |
| 15 | |
Jonathan Hart | c397cf2 | 2015-03-27 08:04:08 -0700 | [diff] [blame] | 16 | # -------------- Setup keys ------------------- |
| 17 | |
| 18 | mkdir -p ~/.ssh |
| 19 | ssh-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 Hart | 2f4271d | 2015-03-26 18:40:57 -0700 | [diff] [blame] | 24 | sudo lxc-create --name onos1 -t download -- --dist ubuntu --release utopic --arch amd64 |
Jonathan Hart | 53433b5 | 2015-03-26 17:23:34 -0700 | [diff] [blame] | 25 | |
Jonathan Hart | c397cf2 | 2015-03-27 08:04:08 -0700 | [diff] [blame] | 26 | sudo sh -c "echo lxc.start.auto=1 >> /var/lib/lxc/onos1/config" |
Jonathan Hart | 53433b5 | 2015-03-26 17:23:34 -0700 | [diff] [blame] | 27 | |
Jonathan Hart | 4bb029f | 2015-03-26 22:45:15 -0700 | [diff] [blame] | 28 | sudo sh -c "sed -i s/dhcp/static/ /var/lib/lxc/onos1/rootfs/etc/network/interfaces" |
| 29 | sudo 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 |
| 34 | EOF" |
| 35 | |
Jonathan Hart | 53433b5 | 2015-03-26 17:23:34 -0700 | [diff] [blame] | 36 | sudo lxc-start --name onos1 --daemon |
Jonathan Hart | c397cf2 | 2015-03-27 08:04:08 -0700 | [diff] [blame] | 37 | |
Jonathan Hart | a897f4e | 2015-03-26 22:31:41 -0700 | [diff] [blame] | 38 | sudo lxc-ls --fancy |
Jonathan Hart | c397cf2 | 2015-03-27 08:04:08 -0700 | [diff] [blame] | 39 | sleep 5 |
Jonathan Hart | a897f4e | 2015-03-26 22:31:41 -0700 | [diff] [blame] | 40 | sudo lxc-ls --fancy |
Jonathan Hart | 17a0039 | 2015-03-26 22:24:25 -0700 | [diff] [blame] | 41 | sudo lxc-attach --name onos1 -- ip a |
Jonathan Hart | c397cf2 | 2015-03-27 08:04:08 -0700 | [diff] [blame] | 42 | |
Jonathan Hart | 53433b5 | 2015-03-26 17:23:34 -0700 | [diff] [blame] | 43 | sudo lxc-attach --name onos1 -- useradd -m sdn -s /bin/bash |
| 44 | sudo lxc-attach --name onos1 -- /bin/bash -c "echo sdn:rocks | chpasswd" |
| 45 | sudo lxc-attach --name onos1 -- /bin/bash -c "echo \"sdn ALL=(ALL) NOPASSWD:ALL\" > /etc/sudoers.d/sdn" |
| 46 | sudo lxc-attach --name onos1 -- apt-get update |
Jonathan Hart | c397cf2 | 2015-03-27 08:04:08 -0700 | [diff] [blame] | 47 | sudo lxc-attach --name onos1 -- apt-get install -y openssh-server openjdk-8-jre-headless |
| 48 | |
Jonathan Hart | 53433b5 | 2015-03-26 17:23:34 -0700 | [diff] [blame] | 49 | sudo lxc-stop --name onos1 |
Jonathan Hart | c397cf2 | 2015-03-27 08:04:08 -0700 | [diff] [blame] | 50 | |
Jonathan Hart | caba161 | 2015-03-27 08:22:16 -0700 | [diff] [blame] | 51 | sudo mkdir -p /var/lib/lxc/onos1/rootfs/home/sdn/.ssh |
Jonathan Hart | c397cf2 | 2015-03-27 08:04:08 -0700 | [diff] [blame] | 52 | sudo cp ~/.ssh/id_rsa.pub /var/lib/lxc/onos1/rootfs/home/sdn/.ssh/authorized_keys |
| 53 | sudo chmod 666 /var/lib/lxc/onos1/rootfs/home/sdn/.ssh/authorized_keys |
| 54 | |
| 55 | sudo lxc-clone onos1 onos2 |
Jonathan Hart | caba161 | 2015-03-27 08:22:16 -0700 | [diff] [blame] | 56 | sudo sh -c "sed -i s/10.0.3.11/10.0.3.12/ /var/lib/lxc/onos2/rootfs/etc/network/interfaces" |
Jonathan Hart | c397cf2 | 2015-03-27 08:04:08 -0700 | [diff] [blame] | 57 | |
| 58 | sudo lxc-clone onos1 onos3 |
Jonathan Hart | caba161 | 2015-03-27 08:22:16 -0700 | [diff] [blame] | 59 | sudo sh -c "sed -i s/10.0.3.11/10.0.3.13/ /var/lib/lxc/onos3/rootfs/etc/network/interfaces" |
Jonathan Hart | c397cf2 | 2015-03-27 08:04:08 -0700 | [diff] [blame] | 60 | |
| 61 | sudo lxc-start --name onos1 |
| 62 | sudo lxc-start --name onos2 |
| 63 | sudo lxc-start --name onos3 |
| 64 | |
| 65 | sleep 5 |
| 66 | |
| 67 | sudo lxc-ls --fancy |
| 68 | |
| 69 | # -------------- Install ONOS ---------------- |
| 70 | |
| 71 | USER=mininet |
| 72 | USER_HOME=/home/${USER} |
| 73 | |
Jonathan Hart | fc7c63f | 2015-03-27 09:32:27 -0700 | [diff] [blame^] | 74 | echo "hello" |
Jonathan Hart | caba161 | 2015-03-27 08:22:16 -0700 | [diff] [blame] | 75 | sudo su - ${USER} |
Jonathan Hart | fc7c63f | 2015-03-27 09:32:27 -0700 | [diff] [blame^] | 76 | echo "chusr" |
| 77 | echo `whoami` |
Jonathan Hart | caba161 | 2015-03-27 08:22:16 -0700 | [diff] [blame] | 78 | |
Jonathan Hart | c397cf2 | 2015-03-27 08:04:08 -0700 | [diff] [blame] | 79 | cd ~ |
| 80 | git clone https://gerrit.onosproject.org/onos |
| 81 | cd onos && git checkout 1.1.0 && cd - |
| 82 | |
Jonathan Hart | caba161 | 2015-03-27 08:22:16 -0700 | [diff] [blame] | 83 | echo ". ~/onos/tools/dev/bash_profile" >> ~/.bashrc |
| 84 | echo "export ONOS_ROOT=${USER_HOME}/onos" >> ~/.bashrc |
| 85 | |
| 86 | exit |
| 87 | sudo su - ${USER} |
| 88 | |
Jonathan Hart | c397cf2 | 2015-03-27 08:04:08 -0700 | [diff] [blame] | 89 | echo $JAVA_HOME |
| 90 | export JAVA_HOME="" |
| 91 | cd $ONOS_ROOT && mvn clean install && mvn dependency:go-offline && cd - |
| 92 | |
| 93 | cat << EOF >> onos/tools/test/cells/tutorial |
| 94 | export ONOS_NIC=10.0.3.* |
| 95 | export OC1="10.0.3.11" |
| 96 | export OC1="10.0.3.12" |
| 97 | export OC1="10.0.3.13" |
| 98 | export OCI="${OC1}" |
| 99 | export ONOS_FEATURES="webconsole,onos-rest,onos-gui,onos-api,onos-core,onos-cli,onos-openflow" |
| 100 | export ONOS_USER="sdn" |
| 101 | EOF |
| 102 | |
| 103 | cell tutorial |
| 104 | |
| 105 | onos-package |
| 106 | onos-group install -f |
| 107 | onos-wait-for-start $OC1 |
| 108 | onos-wait-for-start $OC2 |
| 109 | onos-wait-for-start $OC3 |
| 110 | |
| 111 | sleep 20 |
Jonathan Hart | fc7c63f | 2015-03-27 09:32:27 -0700 | [diff] [blame^] | 112 | onos 1 "nodes" |
| 113 | |
| 114 | exit |