Moshe | 0bb532c | 2018-02-26 13:39:57 +0200 | [diff] [blame] | 1 | #!/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 |
| 19 | DOCKER_ARCH="$(uname -m)" |
| 20 | |
| 21 | UBUNTU_PORTS_URL="http://ports.ubuntu.com/ubuntu-ports/" |
| 22 | UBUNTU_ARCHIVE_URL="http://archive.ubuntu.com/ubuntu/" |
| 23 | |
| 24 | source /etc/os-release |
| 25 | source_file=/etc/apt/sources.list |
| 26 | NSB_DIR="/opt/nsb_bin" |
| 27 | |
| 28 | if [[ "${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 |
| 35 | else |
| 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 |
| 42 | fi |
| 43 | |
| 44 | sed -i -e 's/^deb-src /# deb-src /g' "${source_file}" |
| 45 | |
| 46 | VERSION_CODENAME=${VERSION_CODENAME:-trusty} |
| 47 | |
| 48 | echo "APT::Default-Release \""${VERSION_CODENAME}"\";" > /etc/apt/apt.conf.d/default-distro |
| 49 | |
| 50 | sub_source_file=/etc/apt/sources.list.d/vnftest.list |
| 51 | touch "${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 |
| 55 | if [[ "${VERSION_CODENAME}" != "xenial" ]]; then |
| 56 | REPO_UPDATE="deb [arch="${DOCKER_ARCH}"] "${DOCKER_REPO}" xenial-updates universe" |
| 57 | fi |
| 58 | |
| 59 | echo -e ""${REPO_UPDATE}" |
| 60 | deb [arch="${EXTRA_ARCH}"] "${EXTRA_REPO}" "${VERSION_CODENAME}" main universe multiverse restricted |
| 61 | deb [arch="${EXTRA_ARCH}"] "${EXTRA_REPO}" "${VERSION_CODENAME}"-updates main universe multiverse restricted |
| 62 | deb [arch="${EXTRA_ARCH}"] "${EXTRA_REPO}" "${VERSION_CODENAME}"-security main universe multiverse restricted |
| 63 | deb [arch="${EXTRA_ARCH}"] "${EXTRA_REPO}" "${VERSION_CODENAME}"-proposed main universe multiverse restricted" > "${sub_source_file}" |
| 64 | |
| 65 | echo "vm.mmap_min_addr = 0" > /etc/sysctl.d/mmap_min_addr.conf |
| 66 | |
| 67 | # install tools |
| 68 | apt-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 | |
| 96 | if [[ "${DOCKER_ARCH}" != "aarch64" ]]; then |
| 97 | apt-get install -y libc6:arm64 |
| 98 | fi |
| 99 | |
| 100 | apt-get -y autoremove && apt-get clean |
| 101 | |
| 102 | git config --global http.sslVerify false |
| 103 | |
| 104 | |
| 105 | # install vnftest + dependencies |
| 106 | easy_install -U pip |
| 107 | pip install -r requirements.txt |
| 108 | pip install -e . |
| 109 | |
| 110 | /bin/bash "${PWD}/docker/uwsgi.sh" |
| 111 | /bin/bash "${PWD}/docker/nginx.sh" |
| 112 | cd "${PWD}/gui" && /bin/bash gui.sh |
| 113 | mkdir -p /etc/nginx/vnftest |
| 114 | mv dist /etc/nginx/vnftest/gui |
| 115 | |
| 116 | mkdir -p ${NSB_DIR} |
| 117 | |
| 118 | wget -P ${NSB_DIR}/ http://artifacts.onap.org/vnftest/third-party/trex_client.tar.gz |
| 119 | tar xvf ${NSB_DIR}/trex_client.tar.gz -C ${NSB_DIR} |
| 120 | rm -f ${NSB_DIR}/trex_client.tar.gz |
| 121 | |
| 122 | service nginx restart |
| 123 | uwsgi -i /etc/vnftest/vnftest.ini |