blob: 1cbea420dabecd5a1861905c6065ac9e1892879c [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 Karthickd49ca4b2016-07-27 11:52:50 -070046if [ $on_cord -eq 0 ]; then
47 apt-get -y install apt-transport-https ca-certificates
48 apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
49 if [ ! -f /etc/apt/sources.list.d/docker.list ]; then
A R Karthickbd82f362016-11-10 15:08:52 -080050 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 -070051 fi
52 apt-get update
53 apt-get purge lxc-docker || true
54 apt-get -y install linux-image-extra-$(uname -r)
55 apt-get -y install apparmor
56 echo "Installing Docker"
57 apt-get -y install docker-engine
A R Karthickc4108fe2016-11-17 15:15:28 -080058 service docker restart
A R Karthick973010f2017-02-06 16:41:51 -080059 sleep 5
A R Karthickd49ca4b2016-07-27 11:52:50 -070060 echo "Verifying Docker installation"
61 docker run --rm hello-world || exit 127
62 docker rmi hello-world
A R Karthickb05acab2016-11-10 15:12:43 -080063 echo "Pulling ONOS latest"
A R Karthickd49ca4b2016-07-27 11:52:50 -070064 docker pull onosproject/onos:latest || exit 127
A R Karthick63815d12017-02-08 11:14:40 -080065else
66 echo "Skipping installation of Docker and ONOS"
A R Karthickd49ca4b2016-07-27 11:52:50 -070067fi
A R Karthick05e85fa2016-12-02 09:20:54 -080068
A R Karthick63815d12017-02-08 11:14:40 -080069apt-get -y install openvswitch-common openvswitch-switch
70apt-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
71
72setup_path=$(dirname $(realpath $0))
73if [ $venv -eq 1 ]; then
74 echo "Making a virtual cord-tester pip installation environment"
75 mkdir -p $setup_path/venv
A R Karthickd7f6ade2017-02-08 12:23:58 -080076 virtualenv $setup_path/venv
A R Karthick63815d12017-02-08 11:14:40 -080077 echo "Installing cord-tester pip packages on the virtual environment"
78 $setup_path/venv/bin/pip install -r $setup_path/requirements.txt
79else
80 echo "Installing cord-tester pip packages on the host"
81 pip install -r $setup_path/requirements.txt
Chetan Gaonker66bff932016-05-09 10:06:37 -070082fi
A R Karthick05e85fa2016-12-02 09:20:54 -080083
A R Karthick63815d12017-02-08 11:14:40 -080084( cd /tmp && git clone https://github.com/jpetazzo/pipework.git && cp -v pipework/pipework /usr/bin && rm -rf pipework )
85
A R Karthick05e85fa2016-12-02 09:20:54 -080086install_ovs() {
87 mkdir -p /root/ovs
88 wget http://openvswitch.org/releases/openvswitch-2.5.0.tar.gz -O /root/ovs/openvswitch-2.5.0.tar.gz && \
89 ( cd /root/ovs && tar zxpvf openvswitch-2.5.0.tar.gz && \
90 cd openvswitch-2.5.0 && \
91 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --disable-ssl && make && make install
92 )
93}
94
95ovs_install=0
96
97if [ -f /usr/bin/ovs-vsctl ] || [ -f /usr/local/bin/ovs-vsctl ]; then
98 ##find the version. Install if ovs version less than 2.5
99 version=`sudo ovs-vsctl --version | head -1 | awk '/[1-9].[0-9].[0-9]/ {print $NF}'`
100 major=$(echo $version | cut -d "." -f1)
101 minor=$(echo $version | cut -d "." -f2)
102 if [ $major -le 2 ]; then
103 if [ $major -lt 2 ]; then
104 ovs_install=1
105 else
106 if [ $minor -lt 5 ]; then
107 ovs_install=1
108 fi
109 fi
110 fi
111else
112 ovs_install=1
113fi
114
115if [ $ovs_install -eq 1 ]; then
116 echo "Installing OVS 2.5.0"
117 service openvswitch-switch stop
118 install_ovs
119fi