Merge "tc076 rst documentation"
[yardstick.git] / tools / ubuntu-server-cloudimg-modify.sh
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2015 Ericsson AB 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 # 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 # iperf3 only available for trusty in backports
27 if [ grep -q trusty /etc/apt/sources.list ]; then
28     if [ $YARD_IMG_ARCH = "arm64" ]; then
29         echo "deb [arch=arm64] http://ports.ubuntu.com/ trusty-backports main restricted universe multiverse" >> /etc/apt/sources.list
30     else
31         echo "deb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse" >> /etc/apt/sources.list
32     fi
33 fi
34 # Workaround for building on CentOS (apt-get is not working with http sources)
35 # sed -i 's/http/ftp/' /etc/apt/sources.list
36
37 # Force apt to use ipv4 due to build problems on LF POD.
38 echo 'Acquire::ForceIPv4 "true";' > /etc/apt/apt.conf.d/99force-ipv4
39
40 # Add hostname to /etc/hosts.
41 # Allow console access via pwd
42 cat <<EOF >/etc/cloud/cloud.cfg.d/10_etc_hosts.cfg
43 manage_etc_hosts: True
44 password: RANDOM
45 chpasswd: { expire: False }
46 ssh_pwauth: True
47 EOF
48 apt-get update
49 if [ $YARD_IMG_ARCH = "arm64" ]; then
50 apt-get install -y \
51     linux-headers-$(echo $VIVID_KERNEL_VERSION | cut -d'-' -f3,4,5) \
52     unzip
53 #resize root parition (/dev/vdb1) It is supposed to be default but the image is booted differently for arm64
54 cat <<EOF >/etc/cloud/cloud.cfg.d/15_growpart.cfg
55 #cloud-config
56 bootcmd:
57  - [growpart, /dev/vdb, 1]
58 EOF
59 fi
60 apt-get install -y \
61     bc \
62     fio \
63     git \
64     gcc \
65     iperf3 \
66     ethtool \
67     iproute2 \
68     linux-tools-common \
69     linux-tools-generic \
70     lmbench \
71     make \
72     netperf \
73     patch \
74     perl \
75     rt-tests \
76     stress \
77     sysstat
78
79 if [ $YARD_IMG_ARCH = "arm64" ]; then
80     wget https://github.com/kdlucas/byte-unixbench/archive/master.zip
81     unzip master.zip && rm master.zip
82     mkdir /opt/tempT
83     mv byte-unixbench-master/UnixBench /opt/tempT
84     sed -i -e 's/OPTON += -march=native -mtune=native/OPTON += -march=armv8-a -mtune=generic/g' \
85     -e 's/OPTON += -march=native/OPTON += -march=armv8-a/g' /opt/tempT/UnixBench/Makefile
86 else
87     git clone https://github.com/kdlucas/byte-unixbench.git /opt/tempT
88 fi
89 make --directory /opt/tempT/UnixBench/
90
91 if [ $YARD_IMG_ARCH = "arm64" ]; then
92     wget https://github.com/beefyamoeba5/ramspeed/archive/master.zip
93     unzip master.zip && rm master.zip
94     mkdir /opt/tempT/RAMspeed
95     mv ramspeed-master/* /opt/tempT/RAMspeed/
96 else
97     git clone https://github.com/beefyamoeba5/ramspeed.git /opt/tempT/RAMspeed
98 fi
99 cd /opt/tempT/RAMspeed/ramspeed-2.6.0
100 mkdir temp
101 bash build.sh
102
103 if [ $YARD_IMG_ARCH = "arm64" ]; then
104     wget https://github.com/beefyamoeba5/cachestat/archive/master.zip
105     unzip master.zip && rm master.zip
106     mv cachestat-master/cachestat /opt/tempT
107 else
108     git clone https://github.com/beefyamoeba5/cachestat.git /opt/tempT/Cachestat
109 fi
110
111 # restore symlink
112 ln -sf /run/resolvconf/resolv.conf /etc/resolv.conf