blob: e1b9449c1b9c53497379545de77474afe6f5e977 [file] [log] [blame]
Carmelo Casconeada7b5b2019-04-23 13:50:03 -07001#!/usr/bin/env bash
2
Carmelo Casconed6615072017-12-15 00:53:43 -08003set -xe
4
Carmelo Casconec5569c22018-04-18 10:09:15 +09005VM_TYPE=${1:-dev}
6
Carmelo Casconef66f7792019-11-21 22:13:09 -08007BAZEL_VER="1.0.0"
Carmelo Casconeada7b5b2019-04-23 13:50:03 -07008CORRETTO_URL="https://d3pxv6yz143wms.cloudfront.net/8.212.04.2/java-1.8.0-amazon-corretto-jdk_8.212.04-2_amd64.deb"
9
10# Disable automatic updates
11systemctl stop apt-daily.timer
12systemctl disable apt-daily.timer
13systemctl disable apt-daily.service
14systemctl stop apt-daily-upgrade.timer
15systemctl disable apt-daily-upgrade.timer
16systemctl disable apt-daily-upgrade.service
17
18# Remove Ubuntu user
19sudo userdel -r -f ubuntu
Carmelo Casconebcb055e2019-01-08 14:33:18 -080020
Carmelo Casconed6615072017-12-15 00:53:43 -080021# Create user sdn
22useradd -m -d /home/sdn -s /bin/bash sdn
Carmelo Casconeada7b5b2019-04-23 13:50:03 -070023usermod -aG sudo sdn
24usermod -aG vboxsf sdn
Carmelo Casconed6615072017-12-15 00:53:43 -080025echo "sdn:rocks" | chpasswd
26echo "sdn ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/99_sdn
27chmod 440 /etc/sudoers.d/99_sdn
Carmelo Casconef11513d2018-01-16 00:31:14 -080028update-locale LC_ALL="en_US.UTF-8"
Carmelo Casconed6615072017-12-15 00:53:43 -080029
Carmelo Casconeada7b5b2019-04-23 13:50:03 -070030# Update and upgrade.
Carmelo Casconed6615072017-12-15 00:53:43 -080031apt-get update
Carmelo Cascone95e5afd2018-07-17 14:45:23 +020032DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
33
Carmelo Casconeada7b5b2019-04-23 13:50:03 -070034wget -O corretto.deb ${CORRETTO_URL}
35
Carmelo Casconec5569c22018-04-18 10:09:15 +090036apt-get -y --no-install-recommends install \
Carmelo Casconeada7b5b2019-04-23 13:50:03 -070037 java-common \
38 ./corretto.deb \
39 maven \
Carmelo Cascone57defd32018-05-11 14:34:01 -070040 avahi-daemon \
41 bridge-utils \
42 git \
43 git-review \
44 htop \
Carmelo Cascone57defd32018-05-11 14:34:01 -070045 python2.7 \
46 python2.7-dev \
Carmelo Casconef11513d2018-01-16 00:31:14 -080047 valgrind \
Carmelo Cascone57defd32018-05-11 14:34:01 -070048 zip unzip \
49 tcpdump \
50 vlan \
51 ntp \
Carmelo Casconeada7b5b2019-04-23 13:50:03 -070052 wget \
53 curl \
54 net-tools \
Carmelo Cascone57defd32018-05-11 14:34:01 -070055 vim nano emacs \
Charles Chan84431b92018-08-16 20:30:09 -070056 arping \
57 gawk \
58 texinfo \
59 build-essential \
60 iptables \
61 automake \
62 autoconf \
63 libtool \
64 isc-dhcp-server
65
Carmelo Casconeada7b5b2019-04-23 13:50:03 -070066rm -f corretto.deb
Carmelo Cascone57defd32018-05-11 14:34:01 -070067
Carmelo Casconeada7b5b2019-04-23 13:50:03 -070068rm -f /usr/bin/python
69ln -s `which python2.7` /usr/bin/python
Carmelo Cascone57defd32018-05-11 14:34:01 -070070
Carmelo Cascone03ae0ac2018-10-11 08:31:59 -070071# Install pip and some python deps (others are defined in install-p4-tools.sh)
Carmelo Cascone57defd32018-05-11 14:34:01 -070072curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
73python2.7 get-pip.py --force-reinstall
74rm -f get-pip.py
Carmelo Casconeada7b5b2019-04-23 13:50:03 -070075pip2.7 install ipaddress
76
77if [[ ${VM_TYPE} = "dev" ]]
78then
79 # Install Bazel
80 BAZEL_SH="bazel-${BAZEL_VER}-installer-linux-x86_64.sh"
81 wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VER}/${BAZEL_SH}
82 chmod +x ${BAZEL_SH}
83 ./${BAZEL_SH}
84 rm -f ${BAZEL_SH}
85fi
Charles Chan84431b92018-08-16 20:30:09 -070086
Carmelo Casconed6615072017-12-15 00:53:43 -080087tee -a /etc/ssh/sshd_config <<EOF
88
89UseDNS no
90EOF
91
Carmelo Casconeada7b5b2019-04-23 13:50:03 -070092sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config