Merge "update lxd image disk format for openstack CLI"
[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=${YARD_IMG_ARCH}] 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 apt-get install -y \
50     bc \
51     fio \
52     git \
53     gcc \
54     iperf3 \
55     ethtool \
56     iproute2 \
57     linux-tools-common \
58     linux-tools-generic \
59     lmbench \
60     make \
61     netperf \
62     patch \
63     perl \
64     rt-tests \
65     stress \
66     sysstat
67
68 CLONE_DEST=/opt/tempT
69
70 # remove before cloning
71 rm -rf -- "${CLONE_DEST}"
72
73 git clone https://github.com/kdlucas/byte-unixbench.git "${CLONE_DEST}"
74
75 make --directory "${CLONE_DEST}/UnixBench/"
76
77 if [ "${YARD_IMG_ARCH}" = "arm64" ]; then
78     wget https://github.com/beefyamoeba5/ramspeed/archive/master.zip
79     unzip master.zip && rm master.zip
80     mkdir "${CLONE_DEST}/RAMspeed"
81     mv ramspeed-master/* "${CLONE_DEST}/RAMspeed/"
82 else
83     git clone https://github.com/beefyamoeba5/ramspeed.git "${CLONE_DEST}/RAMspeed"
84 fi
85 cd "${CLONE_DEST}/RAMspeed/ramspeed-2.6.0"
86 mkdir temp
87 bash build.sh
88
89 git clone https://github.com/beefyamoeba5/cachestat.git "${CLONE_DEST}/Cachestat"
90
91 # restore symlink
92 ln -sf /run/resolvconf/resolv.conf /etc/resolv.conf