blob: 173e444ca742ec8c5295b54d58bd9320e29f9a86 [file] [log] [blame]
Carmelo Casconed6615072017-12-15 00:53:43 -08001#!/bin/bash
2set -xe
3
Carmelo Casconeada7b5b2019-04-23 13:50:03 -07004VM_TYPE=${1:-unknown}
5USE_STRATUM=${2:-false}
6
7cd /home/sdn
Carmelo Casconebcb055e2019-01-08 14:33:18 -08008
Carmelo Casconed6615072017-12-15 00:53:43 -08009cp /etc/skel/.bashrc ~/
10cp /etc/skel/.profile ~/
11cp /etc/skel/.bash_logout ~/
12
Carmelo Casconeada7b5b2019-04-23 13:50:03 -070013# With Ubuntu 18.04 sometimes .cache is owned by root...
14mkdir -p ~/.cache
15sudo chown -hR sdn:sdn ~/.cache
16
17echo 'export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")' >> ~/.bash_aliases
18
19if [[ ${VM_TYPE} = "dev" ]]
20then
21 git clone https://github.com/opennetworkinglab/onos.git
22 tee -a ~/.bash_aliases <<'EOF'
Carmelo Casconeb7e618d2018-01-12 18:31:33 -080023
24# ONOS
25export ONOS_ROOT=~/onos
26source ~/onos/tools/dev/bash_profile
Carmelo Casconef11513d2018-01-16 00:31:14 -080027source ~/onos/tools/dev/p4vm/bm-commands.sh
Carmelo Casconeada7b5b2019-04-23 13:50:03 -070028
29export OCI=127.0.0.1
30# Uncomment if ONOS runs on the host system and we access the VM via ssh
31# export OCI=`echo $SSH_CLIENT | awk '{ print $1}'`
32
33export OC1=$OCI
34export ONOS_APPS=gui,drivers.bmv2,lldpprovider,hostprovider
Carmelo Casconeb7e618d2018-01-12 18:31:33 -080035EOF
Carmelo Casconeada7b5b2019-04-23 13:50:03 -070036else
37 # Tutorial. Install ONOS release.
38 cp /vagrant/tmp/onos.tar.gz ~/
39 echo 'export OCI=127.0.0.1' >> ~/.bash_aliases
40 echo 'export OC1=$OCI' >> ~/.bash_aliases
41 echo 'export ONOS_INSTANCES="$OC1"' >> ~/.bash_aliases
42 echo 'export ONOS_WEB_USER=onos' >> ~/.bash_aliases
43 echo 'export ONOS_WEB_PASS=rocks' >> ~/.bash_aliases
44 echo 'export ONOS_APPS=gui,drivers.bmv2,lldpprovider,hostprovider' >> ~/.bash_aliases
45 cp /vagrant/start_onos.sh ~/
46 chmod +x ~/start_onos.sh
47 # onos-admin commands
48 mkdir ~/onos-admin
49 tar xzf /vagrant/tmp/onos-admin.tar.gz -C onos-admin --strip-components 1
50 echo 'export PATH=$PATH:~/onos-admin' >> ~/.bash_aliases
51 # Maven artifacts
52 mkdir -p ~/.m2/repository/org/onosproject
53 cp -r /vagrant/tmp/artifacts/* ~/.m2/repository/org/onosproject/
54 # Export alias for bm-* commands
55 cp /vagrant/bm-commands.sh ~/
56 echo 'source ~/bm-commands.sh' >> ~/.bash_aliases
57 # BMv2 custom Mininet switch classes.
58 cp /vagrant/tmp/bmv2.py ~/
59 echo 'export BMV2_MN_PY=~/bmv2.py' >> ~/.bash_aliases
60 if [[ ${USE_STRATUM} = true ]]
61 then
62 # Install stratum_bmv2 binary.
63 mkdir stratum
64 tar xzf /vagrant/tmp/stratum_bmv2.tar.gz -C stratum --strip-components 1
65 fi
66fi
Carmelo Casconed6615072017-12-15 00:53:43 -080067
68# Build and install P4 tools
Carmelo Casconeada7b5b2019-04-23 13:50:03 -070069DEBUG_FLAGS=true FAST_BUILD=true USE_STRATUM=false bash /vagrant/install-p4-tools.sh
70echo 'export BMV2_INSTALL=/usr/local' >> ~/.bash_aliases
71if [[ ${USE_STRATUM} = true ]]
72then
73 # Rebuild and install PI/BMv2 with stratum config parameters. Building first
74 # without stratum parameters is useful to get P4Runtime Python binding
75 # installed as well as simple_switch_grpc.
76 rm -rf ~/p4tools/bmv2/.last_built_commit*
77 rm -rf ~/p4tools/PI/.last_built_commit*
78 # Build up until bmv2. No need to re-build p4c and others.
79 DEBUG_FLAGS=true FAST_BUILD=true USE_STRATUM=true bash /vagrant/install-p4-tools.sh bmv2
80 echo 'export STRATUM_ROOT=~/stratum' >> ~/.bash_aliases
81fi
82
Carmelo Cascone95e5afd2018-07-17 14:45:23 +020083# We'll delete bmv2 sources later...
84cp ~/p4tools/bmv2/tools/veth_setup.sh ~/veth_setup.sh
85cp ~/p4tools/bmv2/tools/veth_teardown.sh ~/veth_teardown.sh
Carmelo Casconed6615072017-12-15 00:53:43 -080086
87# Mininet
Carmelo Cascone95e5afd2018-07-17 14:45:23 +020088git clone git://github.com/mininet/mininet
Carmelo Cascone57defd32018-05-11 14:34:01 -070089sudo ~/mininet/util/install.sh -nv
Andrea Campanella4f9085e2018-05-29 12:04:16 +020090
Carmelo Casconeada7b5b2019-04-23 13:50:03 -070091if [[ ${VM_TYPE} = "dev" ]]
92then
93 # Trellis - checkout routing repo
94 git clone https://github.com/opennetworkinglab/routing.git
95 # Trellis - install Quagga
96 git clone -b onos-1.11 https://gerrit.opencord.org/quagga
97 cd quagga
98 ./bootstrap.sh
99 ./configure --enable-fpm --sbindir=/usr/lib/quagga enable_user=root enable_group=root
100 make
101 sudo make install
102 cd ..
103 sudo ldconfig
104 # Trellis - modify apparmor for the DHCP to run properly
105 sudo /etc/init.d/apparmor stop
106 sudo ln -s /etc/apparmor.d/usr.sbin.dhcpd /etc/apparmor.d/disable/
107 sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.dhcpd
108 sudo sed -i '30i /var/lib/dhcp{,3}/dhcpclient* lrw,' /etc/apparmor.d/sbin.dhclient
109 sudo /etc/init.d/apparmor start
110 # fabric-p4test
111 git clone https://github.com/opennetworkinglab/fabric-p4test.git
112fi