Merge "TC 088 and TC 089 gives error openstack command not found"
[yardstick.git] / install.sh
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 # fit for arm64
12 DOCKER_ARCH="$(uname -m)"
13
14 UBUNTU_PORTS_URL="http://ports.ubuntu.com/ubuntu-ports/"
15 UBUNTU_ARCHIVE_URL="http://archive.ubuntu.com/ubuntu/"
16
17 source /etc/os-release
18 source_file=/etc/apt/sources.list
19 NSB_DIR="/opt/nsb_bin"
20
21 if [[ "${DOCKER_ARCH}" == "aarch64" ]]; then
22     sed -i -e 's/^deb \([^/[]\)/deb [arch=arm64] \1/g' "${source_file}"
23     DOCKER_ARCH="arm64"
24     DOCKER_REPO="${UBUNTU_PORTS_URL}"
25     EXTRA_ARCH="amd64"
26     EXTRA_REPO="${UBUNTU_ARCHIVE_URL}"
27     dpkg --add-architecture amd64
28 else
29     sed -i -e 's/^deb \([^/[]\)/deb [arch=amd64] \1/g' "${source_file}"
30     DOCKER_ARCH="amd64"
31     DOCKER_REPO="${UBUNTU_ARCHIVE_URL}"
32     EXTRA_ARCH="arm64"
33     EXTRA_REPO="${UBUNTU_PORTS_URL}"
34     dpkg --add-architecture arm64
35 fi
36
37 sed -i -e 's/^deb-src /# deb-src /g' "${source_file}"
38
39 VERSION_CODENAME=${VERSION_CODENAME:-trusty}
40
41 echo "APT::Default-Release \""${VERSION_CODENAME}"\";" > /etc/apt/apt.conf.d/default-distro
42
43 sub_source_file=/etc/apt/sources.list.d/yardstick.list
44 touch "${sub_source_file}"
45
46 # first add xenial repo needed for installing qemu_static_user/xenial in the container
47 # then add complementary architecture repositories in case the cloud image is of different arch
48 if [[ "${VERSION_CODENAME}" != "xenial" ]]; then
49     REPO_UPDATE="deb [arch="${DOCKER_ARCH}"] "${DOCKER_REPO}" xenial-updates universe"
50 fi
51
52 echo -e ""${REPO_UPDATE}"
53 deb [arch="${EXTRA_ARCH}"] "${EXTRA_REPO}" "${VERSION_CODENAME}" main universe multiverse restricted
54 deb [arch="${EXTRA_ARCH}"] "${EXTRA_REPO}" "${VERSION_CODENAME}"-updates main universe multiverse restricted
55 deb [arch="${EXTRA_ARCH}"] "${EXTRA_REPO}" "${VERSION_CODENAME}"-security main universe multiverse restricted
56 deb [arch="${EXTRA_ARCH}"] "${EXTRA_REPO}" "${VERSION_CODENAME}"-proposed main universe multiverse restricted" > "${sub_source_file}"
57
58 echo "vm.mmap_min_addr = 0" > /etc/sysctl.d/mmap_min_addr.conf
59
60 # install tools
61 apt-get update && apt-get install -y \
62     qemu-user-static/xenial \
63     bonnie++ \
64     wget \
65     expect \
66     curl \
67     git \
68     sshpass \
69     qemu-utils \
70     kpartx \
71     libffi-dev \
72     libssl-dev \
73     libzmq-dev \
74     python \
75     python-dev \
76     libxml2-dev \
77     libxslt1-dev \
78     nginx \
79     uwsgi \
80     uwsgi-plugin-python \
81     supervisor \
82     python-pip \
83     vim \
84     libxft-dev \
85     libxss-dev \
86     sudo \
87     iputils-ping \
88     rabbitmq-server
89
90 if [[ "${DOCKER_ARCH}" != "aarch64" ]]; then
91     apt-get install -y libc6:arm64
92 fi
93
94 apt-get -y autoremove && apt-get clean
95
96 git config --global http.sslVerify false
97
98 # Start and configure RabbitMQ
99 service rabbitmq-server restart
100 rabbitmqctl start_app
101 rabbitmqctl add_user yardstick yardstick
102 rabbitmqctl set_permissions yardstick ".*" ".*" ".*"
103
104 # install yardstick + dependencies
105 easy_install -U pip==9.0.1
106 pip install -r requirements.txt
107 pip install -e .
108
109 /bin/bash "${PWD}/docker/uwsgi.sh"
110 /bin/bash "${PWD}/docker/nginx.sh"
111 cd "${PWD}/gui" && /bin/bash gui.sh
112 mkdir -p /etc/nginx/yardstick
113 mv dist /etc/nginx/yardstick/gui
114
115 mkdir -p ${NSB_DIR}
116
117 wget -P ${NSB_DIR}/ http://artifacts.opnfv.org/yardstick/third-party/trex_client.tar.gz
118 tar xvf ${NSB_DIR}/trex_client.tar.gz -C ${NSB_DIR}
119 rm -f ${NSB_DIR}/trex_client.tar.gz
120
121 service nginx restart
122 uwsgi -i /etc/yardstick/yardstick.ini