Merge "Add more parameters in iperf3 taml"
[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_file=/etc/apt/sources.list
18
19 if [[ "${DOCKER_ARCH}" == "aarch64" ]]; then
20     sed -i -e 's/^deb \([^/[]\)/deb [arch=arm64] \1/g' "${source_file}"
21     DOCKER_ARCH="arm64"
22     DOCKER_REPO="${UBUNTU_PORTS_URL}"
23     EXTRA_ARCH="amd64"
24     EXTRA_REPO="${UBUNTU_ARCHIVE_URL}"
25     dpkg --add-architecture amd64
26 else
27     sed -i -e 's/^deb \([^/[]\)/deb [arch=amd64] \1/g' "${source_file}"
28     DOCKER_ARCH="amd64"
29     DOCKER_REPO="${UBUNTU_ARCHIVE_URL}"
30     EXTRA_ARCH="arm64"
31     EXTRA_REPO="${UBUNTU_PORTS_URL}"
32     dpkg --add-architecture arm64
33 fi
34
35 sed -i -e 's/^deb-src /# deb-src /g' "${source_file}"
36 echo "APT::Default-Release \"trusty\";" > /etc/apt/apt.conf.d/default-distro
37
38 sub_source_file=/etc/apt/sources.list.d/yardstick.list
39 touch "${sub_source_file}"
40
41 # first add xenial repo needed for installing qemu_static_user/xenial in the container
42 # then add complementary architecture repositories in case the cloud image is of different arch
43 echo -e "deb [arch="${DOCKER_ARCH}"] "${DOCKER_REPO}" xenial-updates universe
44 deb [arch="${EXTRA_ARCH}"] "${EXTRA_REPO}" trusty main universe multiverse restricted
45 deb [arch="${EXTRA_ARCH}"] "${EXTRA_REPO}" trusty-updates main universe multiverse restricted
46 deb [arch="${EXTRA_ARCH}"] "${EXTRA_REPO}" trusty-security main universe multiverse restricted
47 deb [arch="${EXTRA_ARCH}"] "${EXTRA_REPO}" trusty-proposed main universe multiverse restricted" > "${sub_source_file}"
48
49 echo "vm.mmap_min_addr = 0" > /etc/sysctl.d/mmap_min_addr.conf
50
51 # install tools
52 apt-get update && apt-get install -y \
53     qemu-user-static/xenial \
54     wget \
55     expect \
56     curl \
57     git \
58     sshpass \
59     qemu-utils \
60     kpartx \
61     libffi-dev \
62     libssl-dev \
63     libzmq-dev \
64     python \
65     python-dev \
66     libxml2-dev \
67     libxslt1-dev \
68     nginx \
69     uwsgi \
70     uwsgi-plugin-python \
71     supervisor \
72     python-pip \
73     vim
74
75 if [[ "${DOCKER_ARCH}" != "aarch64" ]]; then
76     apt-get install -y libc6:arm64
77 fi
78
79 apt-get -y autoremove && apt-get clean
80
81 git config --global http.sslVerify false
82
83
84 # install yardstick + dependencies
85 easy_install -U pip
86 pip install -r requirements.txt
87 pip install -e .
88
89 /bin/bash "${PWD}/docker/uwsgi.sh"
90 /bin/bash "${PWD}/docker/nginx.sh"
91 cd "${PWD}/gui" && /bin/bash gui.sh
92 mkdir -p /etc/nginx/yardstick
93 mv dist /etc/nginx/yardstick/gui
94
95 service nginx restart
96 uwsgi -i /etc/yardstick/yardstick.ini