Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | set -xe |
| 3 | |
Carmelo Cascone | ada7b5b | 2019-04-23 13:50:03 -0700 | [diff] [blame] | 4 | VM_TYPE=${1:-unknown} |
| 5 | USE_STRATUM=${2:-false} |
| 6 | |
| 7 | cd /home/sdn |
Carmelo Cascone | bcb055e | 2019-01-08 14:33:18 -0800 | [diff] [blame] | 8 | |
Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 9 | cp /etc/skel/.bashrc ~/ |
| 10 | cp /etc/skel/.profile ~/ |
| 11 | cp /etc/skel/.bash_logout ~/ |
| 12 | |
Carmelo Cascone | ada7b5b | 2019-04-23 13:50:03 -0700 | [diff] [blame] | 13 | # With Ubuntu 18.04 sometimes .cache is owned by root... |
| 14 | mkdir -p ~/.cache |
| 15 | sudo chown -hR sdn:sdn ~/.cache |
| 16 | |
| 17 | echo 'export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")' >> ~/.bash_aliases |
| 18 | |
| 19 | if [[ ${VM_TYPE} = "dev" ]] |
| 20 | then |
| 21 | git clone https://github.com/opennetworkinglab/onos.git |
| 22 | tee -a ~/.bash_aliases <<'EOF' |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 23 | |
| 24 | # ONOS |
| 25 | export ONOS_ROOT=~/onos |
| 26 | source ~/onos/tools/dev/bash_profile |
Carmelo Cascone | f11513d | 2018-01-16 00:31:14 -0800 | [diff] [blame] | 27 | source ~/onos/tools/dev/p4vm/bm-commands.sh |
Carmelo Cascone | ada7b5b | 2019-04-23 13:50:03 -0700 | [diff] [blame] | 28 | |
| 29 | export 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 | |
| 33 | export OC1=$OCI |
| 34 | export ONOS_APPS=gui,drivers.bmv2,lldpprovider,hostprovider |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 35 | EOF |
Carmelo Cascone | ada7b5b | 2019-04-23 13:50:03 -0700 | [diff] [blame] | 36 | else |
| 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 |
| 66 | fi |
Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 67 | |
| 68 | # Build and install P4 tools |
Carmelo Cascone | ada7b5b | 2019-04-23 13:50:03 -0700 | [diff] [blame] | 69 | DEBUG_FLAGS=true FAST_BUILD=true USE_STRATUM=false bash /vagrant/install-p4-tools.sh |
| 70 | echo 'export BMV2_INSTALL=/usr/local' >> ~/.bash_aliases |
| 71 | if [[ ${USE_STRATUM} = true ]] |
| 72 | then |
| 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 |
| 81 | fi |
| 82 | |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 83 | # We'll delete bmv2 sources later... |
| 84 | cp ~/p4tools/bmv2/tools/veth_setup.sh ~/veth_setup.sh |
| 85 | cp ~/p4tools/bmv2/tools/veth_teardown.sh ~/veth_teardown.sh |
Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 86 | |
| 87 | # Mininet |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 88 | git clone git://github.com/mininet/mininet |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 89 | sudo ~/mininet/util/install.sh -nv |
Andrea Campanella | 4f9085e | 2018-05-29 12:04:16 +0200 | [diff] [blame] | 90 | |
Carmelo Cascone | ada7b5b | 2019-04-23 13:50:03 -0700 | [diff] [blame] | 91 | if [[ ${VM_TYPE} = "dev" ]] |
| 92 | then |
| 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 |
| 112 | fi |