Offline support for bottlenecks project
[yardstick.git] / tools / vsperf-img-modify.sh
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2017 Nokia
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 # installs required packages
12 # must be run from inside the image (either chrooted or running)
13
14 set -ex
15
16 if [ $# -eq 1 ]; then
17     nameserver_ip=$1
18
19     # /etc/resolv.conf is a symbolic link to /run, restore at end
20     rm /etc/resolv.conf
21     echo "nameserver $nameserver_ip" > /etc/resolv.conf
22     echo "nameserver 8.8.8.8" >> /etc/resolv.conf
23     echo "nameserver 8.8.4.4" >> /etc/resolv.conf
24 fi
25
26 # Force apt to use ipv4 due to build problems on LF POD.
27 echo 'Acquire::ForceIPv4 "true";' > /etc/apt/apt.conf.d/99force-ipv4
28
29 echo 'GRUB_CMDLINE_LINUX="resume=/dev/sda1 default_hugepagesz=1G hugepagesz=1G hugepages=32 iommu=on iommu=pt intel_iommu=on"' >> /etc/default/grub
30
31 # Add hostname to /etc/hosts.
32 # Allow console access via pwd
33 cat <<EOF >/etc/cloud/cloud.cfg.d/10_etc_hosts.cfg
34 manage_etc_hosts: True
35 password: ubuntu
36 chpasswd: { expire: False }
37 ssh_pwauth: True
38 EOF
39
40 linuxheadersversion=`echo ls boot/vmlinuz* | cut -d- -f2-`
41
42 apt-get update
43 apt-get install -y \
44     linux-headers-$linuxheadersversion \
45     screen \
46     locate \
47     sshpass \
48     git
49
50 cd /root
51 git clone -b stable/danube https://gerrit.opnfv.org/gerrit/vswitchperf
52
53 # do not compile ovs and qemu
54 sed -i.bak -e 's/^\(SUBBUILDS\ =\ src_vanilla\)/#\1/' \
55            -e 's/^\(SUBDIRS\ += ovs.*\)/#\1/' \
56            -e 's/^\(SUBDIRS\ += qemu.*\)/#\1/' \
57     vswitchperf/src/Makefile
58 # If these paths do not exist, vsperf wont start
59 mkdir -p /root/vswitchperf/src/ovs/ovs/ovsdb/
60 touch /root/vswitchperf/src/ovs/ovs/ovsdb/ovsdb-tool
61 touch /root/vswitchperf/src/ovs/ovs/ovsdb/ovsdb-server
62 mkdir -p /root/vswitchperf/src/qemu/qemu/x86_64-softmmu/
63 touch /root/vswitchperf/src/qemu/qemu/x86_64-softmmu/qemu-system-x86_64
64 mkdir -p /root/vswitchperf/src/ovs/ovs/utilities/
65 touch /root/vswitchperf/src/ovs/ovs/utilities/ovs-dpctl
66 touch /root/vswitchperf/src/ovs/ovs/utilities/ovs-vsctl
67 touch /root/vswitchperf/src/ovs/ovs/utilities/ovs-ofctl
68 touch /root/vswitchperf/src/ovs/ovs/utilities/ovs-appctl
69 mkdir -p /root/vswitchperf/src/ovs/ovs/vswitchd/
70 touch /root/vswitchperf/src/ovs/ovs/vswitchd/vswitch.ovsschema
71 touch /root/vswitchperf/src/ovs/ovs/vswitchd/ovs-vswitchd
72
73 # restore symlink
74 #ln -sf /run/resolvconf/resolv.conf /etc/resolv.conf