blob: 75813c593d768cc1132b331a2e388e7074861657 [file] [log] [blame]
Moshe0bb532c2018-02-26 13:39:57 +02001#!/bin/bash
2##############################################################################
3# Copyright 2018 EuropeanSoftwareMarketingLtd.
4# ===================================================================
5# Licensed under the ApacheLicense, Version2.0 (the"License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# software distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and limitations under
13# the License
14##############################################################################
15# vnftest comment: this is a modified copy of
16# yardstick/install.sh
17
18# fit for arm64
19DOCKER_ARCH="$(uname -m)"
20
21UBUNTU_PORTS_URL="http://ports.ubuntu.com/ubuntu-ports/"
22UBUNTU_ARCHIVE_URL="http://archive.ubuntu.com/ubuntu/"
23
24source /etc/os-release
25source_file=/etc/apt/sources.list
26NSB_DIR="/opt/nsb_bin"
27
28if [[ "${DOCKER_ARCH}" == "aarch64" ]]; then
29 sed -i -e 's/^deb \([^/[]\)/deb [arch=arm64] \1/g' "${source_file}"
30 DOCKER_ARCH="arm64"
31 DOCKER_REPO="${UBUNTU_PORTS_URL}"
32 EXTRA_ARCH="amd64"
33 EXTRA_REPO="${UBUNTU_ARCHIVE_URL}"
34 dpkg --add-architecture amd64
35else
36 sed -i -e 's/^deb \([^/[]\)/deb [arch=amd64] \1/g' "${source_file}"
37 DOCKER_ARCH="amd64"
38 DOCKER_REPO="${UBUNTU_ARCHIVE_URL}"
39 EXTRA_ARCH="arm64"
40 EXTRA_REPO="${UBUNTU_PORTS_URL}"
41 dpkg --add-architecture arm64
42fi
43
44sed -i -e 's/^deb-src /# deb-src /g' "${source_file}"
45
46VERSION_CODENAME=${VERSION_CODENAME:-trusty}
47
48echo "APT::Default-Release \""${VERSION_CODENAME}"\";" > /etc/apt/apt.conf.d/default-distro
49
50sub_source_file=/etc/apt/sources.list.d/vnftest.list
51touch "${sub_source_file}"
52
53# first add xenial repo needed for installing qemu_static_user/xenial in the container
54# then add complementary architecture repositories in case the cloud image is of different arch
55if [[ "${VERSION_CODENAME}" != "xenial" ]]; then
56 REPO_UPDATE="deb [arch="${DOCKER_ARCH}"] "${DOCKER_REPO}" xenial-updates universe"
57fi
58
59echo -e ""${REPO_UPDATE}"
60deb [arch="${EXTRA_ARCH}"] "${EXTRA_REPO}" "${VERSION_CODENAME}" main universe multiverse restricted
61deb [arch="${EXTRA_ARCH}"] "${EXTRA_REPO}" "${VERSION_CODENAME}"-updates main universe multiverse restricted
62deb [arch="${EXTRA_ARCH}"] "${EXTRA_REPO}" "${VERSION_CODENAME}"-security main universe multiverse restricted
63deb [arch="${EXTRA_ARCH}"] "${EXTRA_REPO}" "${VERSION_CODENAME}"-proposed main universe multiverse restricted" > "${sub_source_file}"
64
65echo "vm.mmap_min_addr = 0" > /etc/sysctl.d/mmap_min_addr.conf
66
67# install tools
68apt-get update && apt-get install -y \
69 qemu-user-static/xenial \
70 bonnie++ \
71 wget \
72 expect \
73 curl \
74 git \
75 sshpass \
76 qemu-utils \
77 kpartx \
78 libffi-dev \
79 libssl-dev \
80 libzmq-dev \
81 python \
82 python-dev \
83 libxml2-dev \
84 libxslt1-dev \
85 nginx \
86 uwsgi \
87 uwsgi-plugin-python \
88 supervisor \
89 python-pip \
90 vim \
91 libxft-dev \
92 libxss-dev \
93 sudo \
94 iputils-ping
95
96if [[ "${DOCKER_ARCH}" != "aarch64" ]]; then
97 apt-get install -y libc6:arm64
98fi
99
100apt-get -y autoremove && apt-get clean
101
102git config --global http.sslVerify false
103
104
105# install vnftest + dependencies
106easy_install -U pip
107pip install -r requirements.txt
108pip install -e .
109
110/bin/bash "${PWD}/docker/uwsgi.sh"
111/bin/bash "${PWD}/docker/nginx.sh"
112cd "${PWD}/gui" && /bin/bash gui.sh
113mkdir -p /etc/nginx/vnftest
114mv dist /etc/nginx/vnftest/gui
115
116mkdir -p ${NSB_DIR}
117
118wget -P ${NSB_DIR}/ http://artifacts.onap.org/vnftest/third-party/trex_client.tar.gz
119tar xvf ${NSB_DIR}/trex_client.tar.gz -C ${NSB_DIR}
120rm -f ${NSB_DIR}/trex_client.tar.gz
121
122service nginx restart
123uwsgi -i /etc/vnftest/vnftest.ini