Carmelo Cascone | ada7b5b | 2019-04-23 13:50:03 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 3 | set -xe |
| 4 | |
Carmelo Cascone | c5569c2 | 2018-04-18 10:09:15 +0900 | [diff] [blame] | 5 | VM_TYPE=${1:-dev} |
| 6 | |
Carmelo Cascone | 212dc2f | 2019-11-21 22:13:09 -0800 | [diff] [blame] | 7 | BAZEL_VER="1.0.0" |
Carmelo Cascone | ada7b5b | 2019-04-23 13:50:03 -0700 | [diff] [blame] | 8 | CORRETTO_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 |
| 11 | systemctl stop apt-daily.timer |
| 12 | systemctl disable apt-daily.timer |
| 13 | systemctl disable apt-daily.service |
| 14 | systemctl stop apt-daily-upgrade.timer |
| 15 | systemctl disable apt-daily-upgrade.timer |
| 16 | systemctl disable apt-daily-upgrade.service |
| 17 | |
| 18 | # Remove Ubuntu user |
| 19 | sudo userdel -r -f ubuntu |
Carmelo Cascone | bcb055e | 2019-01-08 14:33:18 -0800 | [diff] [blame] | 20 | |
Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 21 | # Create user sdn |
| 22 | useradd -m -d /home/sdn -s /bin/bash sdn |
Carmelo Cascone | ada7b5b | 2019-04-23 13:50:03 -0700 | [diff] [blame] | 23 | usermod -aG sudo sdn |
| 24 | usermod -aG vboxsf sdn |
Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 25 | echo "sdn:rocks" | chpasswd |
| 26 | echo "sdn ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/99_sdn |
| 27 | chmod 440 /etc/sudoers.d/99_sdn |
Carmelo Cascone | f11513d | 2018-01-16 00:31:14 -0800 | [diff] [blame] | 28 | update-locale LC_ALL="en_US.UTF-8" |
Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 29 | |
Carmelo Cascone | ada7b5b | 2019-04-23 13:50:03 -0700 | [diff] [blame] | 30 | # Update and upgrade. |
Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 31 | apt-get update |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 32 | DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade |
| 33 | |
Carmelo Cascone | ada7b5b | 2019-04-23 13:50:03 -0700 | [diff] [blame] | 34 | wget -O corretto.deb ${CORRETTO_URL} |
| 35 | |
Carmelo Cascone | c5569c2 | 2018-04-18 10:09:15 +0900 | [diff] [blame] | 36 | apt-get -y --no-install-recommends install \ |
Carmelo Cascone | ada7b5b | 2019-04-23 13:50:03 -0700 | [diff] [blame] | 37 | java-common \ |
| 38 | ./corretto.deb \ |
| 39 | maven \ |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 40 | avahi-daemon \ |
| 41 | bridge-utils \ |
| 42 | git \ |
| 43 | git-review \ |
| 44 | htop \ |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 45 | python2.7 \ |
| 46 | python2.7-dev \ |
Carmelo Cascone | f11513d | 2018-01-16 00:31:14 -0800 | [diff] [blame] | 47 | valgrind \ |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 48 | zip unzip \ |
| 49 | tcpdump \ |
| 50 | vlan \ |
| 51 | ntp \ |
Carmelo Cascone | ada7b5b | 2019-04-23 13:50:03 -0700 | [diff] [blame] | 52 | wget \ |
| 53 | curl \ |
| 54 | net-tools \ |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 55 | vim nano emacs \ |
Charles Chan | 84431b9 | 2018-08-16 20:30:09 -0700 | [diff] [blame] | 56 | arping \ |
| 57 | gawk \ |
| 58 | texinfo \ |
| 59 | build-essential \ |
| 60 | iptables \ |
| 61 | automake \ |
| 62 | autoconf \ |
| 63 | libtool \ |
| 64 | isc-dhcp-server |
| 65 | |
Carmelo Cascone | ada7b5b | 2019-04-23 13:50:03 -0700 | [diff] [blame] | 66 | rm -f corretto.deb |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 67 | |
Carmelo Cascone | ada7b5b | 2019-04-23 13:50:03 -0700 | [diff] [blame] | 68 | rm -f /usr/bin/python |
| 69 | ln -s `which python2.7` /usr/bin/python |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 70 | |
Carmelo Cascone | 03ae0ac | 2018-10-11 08:31:59 -0700 | [diff] [blame] | 71 | # Install pip and some python deps (others are defined in install-p4-tools.sh) |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 72 | curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py |
| 73 | python2.7 get-pip.py --force-reinstall |
| 74 | rm -f get-pip.py |
Carmelo Cascone | ada7b5b | 2019-04-23 13:50:03 -0700 | [diff] [blame] | 75 | pip2.7 install ipaddress |
| 76 | |
| 77 | if [[ ${VM_TYPE} = "dev" ]] |
| 78 | then |
| 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} |
| 85 | fi |
Charles Chan | 84431b9 | 2018-08-16 20:30:09 -0700 | [diff] [blame] | 86 | |
Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 87 | tee -a /etc/ssh/sshd_config <<EOF |
| 88 | |
| 89 | UseDNS no |
| 90 | EOF |
| 91 | |
Carmelo Cascone | ada7b5b | 2019-04-23 13:50:03 -0700 | [diff] [blame] | 92 | sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config |