blob: 480fe7350aa27e8d7f268d4b73b6e081e73e4376 [file] [log] [blame]
Chetan Gaonkercc19ac42016-05-04 17:21:50 -07001#!/usr/bin/env bash
A R Karthick63815d12017-02-08 11:14:40 -08002
3function usage {
4 echo "usage: ${0#*/} [-h |--help] [--cord] [--venv]"
5 exit 1
6}
7
A R Karthickd49ca4b2016-07-27 11:52:50 -07008on_cord=0
A R Karthick63815d12017-02-08 11:14:40 -08009venv=0
10optspec=":h-:"
11while getopts "$optspec" optchar; do
12 case "${optchar}" in
13 -)
14 case "${OPTARG}" in
15 cord)
16 on_cord=1
A R Karthick63815d12017-02-08 11:14:40 -080017 ;;
18 venv)
19 venv=1
A R Karthick63815d12017-02-08 11:14:40 -080020 ;;
21 help)
22 usage
23 ;;
24 *)
25 echo "Unknown option --${OPTARG}"
26 usage
27 ;;
28 esac
29 ;;
30 h)
31 usage
32 ;;
33 *)
34 usage
35 ;;
36 esac
37done
38
39shift $((OPTIND-1))
40if [ $# -gt 0 ]; then
41 usage
Chetan Gaonkercc19ac42016-05-04 17:21:50 -070042fi
A R Karthick63815d12017-02-08 11:14:40 -080043
44apt-get update
45release=$(lsb_release -cs)
A R Karthick66cf6f62017-02-28 14:04:34 -080046#install docker only if not installed already. On cord, its mostly installed.
47if $(which docker 2>&1 >/dev/null); then
48 on_cord=1
49else
50 on_cord=0
51fi
A R Karthickd49ca4b2016-07-27 11:52:50 -070052if [ $on_cord -eq 0 ]; then
53 apt-get -y install apt-transport-https ca-certificates
54 apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
55 if [ ! -f /etc/apt/sources.list.d/docker.list ]; then
A R Karthickbd82f362016-11-10 15:08:52 -080056 echo deb https://apt.dockerproject.org/repo ubuntu-$release main | tee /etc/apt/sources.list.d/docker.list
A R Karthickd49ca4b2016-07-27 11:52:50 -070057 fi
58 apt-get update
59 apt-get purge lxc-docker || true
60 apt-get -y install linux-image-extra-$(uname -r)
61 apt-get -y install apparmor
62 echo "Installing Docker"
63 apt-get -y install docker-engine
A R Karthickc4108fe2016-11-17 15:15:28 -080064 service docker restart
A R Karthick973010f2017-02-06 16:41:51 -080065 sleep 5
A R Karthickd49ca4b2016-07-27 11:52:50 -070066 echo "Verifying Docker installation"
67 docker run --rm hello-world || exit 127
68 docker rmi hello-world
A R Karthickb05acab2016-11-10 15:12:43 -080069 echo "Pulling ONOS latest"
A R Karthickd49ca4b2016-07-27 11:52:50 -070070 docker pull onosproject/onos:latest || exit 127
A R Karthick63815d12017-02-08 11:14:40 -080071else
72 echo "Skipping installation of Docker and ONOS"
A R Karthickd49ca4b2016-07-27 11:52:50 -070073fi
A R Karthick05e85fa2016-12-02 09:20:54 -080074
A R Karthick63815d12017-02-08 11:14:40 -080075apt-get -y install openvswitch-common openvswitch-switch
76apt-get -y install wget git python python-dev python-pip python-setuptools python-scapy python-pexpect python-maas-client tcpdump arping libssl-dev libffi-dev realpath python-virtualenv
77
78setup_path=$(dirname $(realpath $0))
79if [ $venv -eq 1 ]; then
80 echo "Making a virtual cord-tester pip installation environment"
81 mkdir -p $setup_path/venv
A R Karthickd7f6ade2017-02-08 12:23:58 -080082 virtualenv $setup_path/venv
A R Karthick63815d12017-02-08 11:14:40 -080083 echo "Installing cord-tester pip packages on the virtual environment"
84 $setup_path/venv/bin/pip install -r $setup_path/requirements.txt
85else
86 echo "Installing cord-tester pip packages on the host"
87 pip install -r $setup_path/requirements.txt
Chetan Gaonker66bff932016-05-09 10:06:37 -070088fi
A R Karthick05e85fa2016-12-02 09:20:54 -080089
A R Karthick63815d12017-02-08 11:14:40 -080090( cd /tmp && git clone https://github.com/jpetazzo/pipework.git && cp -v pipework/pipework /usr/bin && rm -rf pipework )
91
A R Karthick05e85fa2016-12-02 09:20:54 -080092install_ovs() {
93 mkdir -p /root/ovs
94 wget http://openvswitch.org/releases/openvswitch-2.5.0.tar.gz -O /root/ovs/openvswitch-2.5.0.tar.gz && \
95 ( cd /root/ovs && tar zxpvf openvswitch-2.5.0.tar.gz && \
96 cd openvswitch-2.5.0 && \
97 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --disable-ssl && make && make install
98 )
99}
100
101ovs_install=0
102
103if [ -f /usr/bin/ovs-vsctl ] || [ -f /usr/local/bin/ovs-vsctl ]; then
104 ##find the version. Install if ovs version less than 2.5
105 version=`sudo ovs-vsctl --version | head -1 | awk '/[1-9].[0-9].[0-9]/ {print $NF}'`
106 major=$(echo $version | cut -d "." -f1)
107 minor=$(echo $version | cut -d "." -f2)
108 if [ $major -le 2 ]; then
109 if [ $major -lt 2 ]; then
110 ovs_install=1
111 else
112 if [ $minor -lt 5 ]; then
113 ovs_install=1
114 fi
115 fi
116 fi
117else
118 ovs_install=1
119fi
120
121if [ $ovs_install -eq 1 ]; then
122 echo "Installing OVS 2.5.0"
123 service openvswitch-switch stop
124 install_ovs
125fi
A R Karthickf7a613b2017-02-24 09:36:44 -0800126
127test_images=(cordtest/radius:candidate cordtest/quagga:candidate cordtest/nose:candidate)
128for img in ${test_images[*]}; do
129 echo "Pulling cord-tester image $img"
130 docker pull $img 2>/dev/null
131done