Handle HTTP traffic profile parameters as optional
[yardstick.git] / tools / ubuntu-server-cloudimg-dpdk-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 wily in backports
27 grep wily /etc/apt/sources.list && \
28     echo "deb http://archive.ubuntu.com/ubuntu/ wily-backports main restricted universe multiverse" >> /etc/apt/sources.list
29
30 # Workaround for building on CentOS (apt-get is not working with http sources)
31 # sed -i 's/http/ftp/' /etc/apt/sources.list
32
33 # Force apt to use ipv4 due to build problems on LF POD.
34 echo 'Acquire::ForceIPv4 "true";' > /etc/apt/apt.conf.d/99force-ipv4
35
36 echo 'GRUB_CMDLINE_LINUX="resume=/dev/sda1 default_hugepagesz=1G hugepagesz=1G hugepages=2 iommu=on iommu=pt intel_iommu=on"' >> /etc/default/grub
37 echo 'vm.nr_hugepages=1024' >> /etc/sysctl.conf
38 echo 'huge /mnt/huge hugetlbfs defaults 0 0' >> vi /etc/fstab
39
40 mkdir /mnt/huge
41 chmod 777 /mnt/huge
42
43 for i in {1..2}
44 do
45     touch /etc/network/interfaces.d/eth$i.cfg
46     chmod 777 /etc/network/interfaces.d/eth$i.cfg
47     echo "auto eth$i" >> /etc/network/interfaces.d/eth$i.cfg
48     echo "iface eth$i inet dhcp" >> /etc/network/interfaces.d/eth$i.cfg
49 done
50
51 # this needs for checking dpdk status, adding interfaces to dpdk, bind, unbind etc..
52
53 # Add hostname to /etc/hosts.
54 # Allow console access via pwd
55 cat <<EOF >/etc/cloud/cloud.cfg.d/10_etc_hosts.cfg
56 manage_etc_hosts: True
57 password: RANDOM
58 chpasswd: { expire: False }
59 ssh_pwauth: True
60 EOF
61
62 linuxheadersversion=$(echo ls /boot/vmlinuz* | cut -d- -f2-)
63
64 apt-get update
65 apt-get install -y \
66     bc \
67     fio \
68     gcc \
69     git \
70     iperf3 \
71     iproute2 \
72     ethtool \
73     linux-tools-common \
74     linux-tools-generic \
75     lmbench \
76     make \
77     unzip \
78     netperf \
79     patch \
80     perl \
81     rt-tests \
82     stress \
83     sysstat \
84     linux-headers-"${linuxheadersversion}" \
85     libpcap-dev \
86     lua5.2 \
87     net-tools \
88     wget \
89     unzip \
90     libpcap-dev \
91     ncurses-dev \
92     libedit-dev \
93     pciutils \
94     pkg-config \
95     liblua5.2-dev \
96     libncursesw5-dev \
97     ncurses-dev \
98     libedit-dev
99
100 dpkg -L liblua5.2-dev
101 cp /usr/include/lua5.2/lua.h /usr/include/
102 cp /usr/include/lua5.2/lua.h /usr/include/x86_64-linux-gnu/
103
104 git clone http://dpdk.org/git/dpdk
105 git clone http://dpdk.org/git/apps/pktgen-dpdk
106
107 CLONE_DEST=/opt/tempT
108 # remove before cloning
109 rm -rf -- "${CLONE_DEST}"
110 git clone https://github.com/kdlucas/byte-unixbench.git "${CLONE_DEST}"
111 make --directory "${CLONE_DEST}/UnixBench/"
112
113 git clone https://github.com/beefyamoeba5/ramspeed.git "${CLONE_DEST}/RAMspeed"
114 cd "${CLONE_DEST}/RAMspeed/ramspeed-2.6.0"
115 mkdir temp
116 bash build.sh
117
118 git clone https://github.com/beefyamoeba5/cachestat.git "${CLONE_DEST}"/Cachestat
119
120 cd /root
121 wget http://dpdk.org/browse/dpdk/snapshot/dpdk-17.02.zip
122 unzip dpdk-17.02.zip
123 cd dpdk-17.02
124 make install T=x86_64-native-linuxapp-gcc
125
126 cd /root
127 wget https://01.org/sites/default/files/downloads/intelr-data-plane-performance-demonstrators/dppd-prox-v035.zip
128 unzip dppd-prox-v035.zip
129 cd dppd-PROX-v035
130 chmod +x helper-scripts/trailing.sh
131 export RTE_SDK=/root/dpdk-17.02
132 export RTE_TARGET=x86_64-native-linuxapp-gcc
133 make
134
135 # restore symlink
136 ln -sfrT /run/resolvconf/resolv.conf /etc/resolv.conf