Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | set -xe |
| 3 | |
Carmelo Cascone | c5569c2 | 2018-04-18 10:09:15 +0900 | [diff] [blame] | 4 | VM_TYPE=${1:-dev} |
| 5 | |
Carmelo Cascone | a1812ad | 2018-08-13 18:57:06 -0700 | [diff] [blame] | 6 | BAZEL_VER="0.15.2" |
| 7 | BAZEL_DEB="bazel_${BAZEL_VER}-linux-x86_64.deb" |
Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 8 | # Create user sdn |
| 9 | useradd -m -d /home/sdn -s /bin/bash sdn |
| 10 | echo "sdn:rocks" | chpasswd |
| 11 | echo "sdn ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/99_sdn |
| 12 | chmod 440 /etc/sudoers.d/99_sdn |
| 13 | usermod -aG vboxsf sdn |
Carmelo Cascone | f11513d | 2018-01-16 00:31:14 -0800 | [diff] [blame] | 14 | update-locale LC_ALL="en_US.UTF-8" |
Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 15 | |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 16 | |
Carmelo Cascone | c5569c2 | 2018-04-18 10:09:15 +0900 | [diff] [blame] | 17 | if [ ${VM_TYPE} = "tutorial" ] |
| 18 | then |
Carmelo Cascone | c5569c2 | 2018-04-18 10:09:15 +0900 | [diff] [blame] | 19 | su sdn <<'EOF' |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 20 | cd /home/sdn |
| 21 | bash /vagrant/tutorial-bootstrap.sh |
Carmelo Cascone | c5569c2 | 2018-04-18 10:09:15 +0900 | [diff] [blame] | 22 | EOF |
Carmelo Cascone | c5569c2 | 2018-04-18 10:09:15 +0900 | [diff] [blame] | 23 | fi |
| 24 | |
Carmelo Cascone | a1812ad | 2018-08-13 18:57:06 -0700 | [diff] [blame] | 25 | # Bazel |
| 26 | wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VER}/${BAZEL_DEB} |
| 27 | |
Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 28 | # Java 8 |
| 29 | apt-get install software-properties-common -y |
| 30 | add-apt-repository ppa:webupd8team/java -y |
| 31 | apt-get update |
Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 32 | |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 33 | DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade |
| 34 | |
| 35 | echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections |
Carmelo Cascone | c5569c2 | 2018-04-18 10:09:15 +0900 | [diff] [blame] | 36 | apt-get -y --no-install-recommends install \ |
Carmelo Cascone | a1812ad | 2018-08-13 18:57:06 -0700 | [diff] [blame] | 37 | ./${BAZEL_DEB} \ |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 38 | avahi-daemon \ |
| 39 | bridge-utils \ |
| 40 | git \ |
| 41 | git-review \ |
| 42 | htop \ |
Carmelo Cascone | c5569c2 | 2018-04-18 10:09:15 +0900 | [diff] [blame] | 43 | oracle-java8-installer \ |
| 44 | oracle-java8-set-default \ |
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 \ |
| 52 | vim nano emacs \ |
Charles Chan | 84431b9 | 2018-08-16 20:30:09 -0700 | [diff] [blame] | 53 | arping \ |
| 54 | gawk \ |
| 55 | texinfo \ |
| 56 | build-essential \ |
| 57 | iptables \ |
| 58 | automake \ |
| 59 | autoconf \ |
| 60 | libtool \ |
| 61 | isc-dhcp-server |
| 62 | |
| 63 | DEBIAN_FRONTEND=noninteractive apt-get -yq install wireshark |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 64 | |
Carmelo Cascone | a1812ad | 2018-08-13 18:57:06 -0700 | [diff] [blame] | 65 | rm -f ${BAZEL_DEB} |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 66 | |
| 67 | curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py |
| 68 | python2.7 get-pip.py --force-reinstall |
| 69 | rm -f get-pip.py |
Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 70 | |
Charles Chan | 84431b9 | 2018-08-16 20:30:09 -0700 | [diff] [blame] | 71 | pip install ipaddress |
| 72 | |
Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 73 | tee -a /etc/ssh/sshd_config <<EOF |
| 74 | |
| 75 | UseDNS no |
| 76 | EOF |
| 77 | |
| 78 | su sdn <<'EOF' |
| 79 | cd /home/sdn |
| 80 | bash /vagrant/user-bootstrap.sh |
| 81 | EOF |