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 | c5569c2 | 2018-04-18 10:09:15 +0900 | [diff] [blame] | 16 | if [ ${VM_TYPE} = "tutorial" ] |
| 17 | then |
Carmelo Cascone | c5569c2 | 2018-04-18 10:09:15 +0900 | [diff] [blame] | 18 | su sdn <<'EOF' |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 19 | cd /home/sdn |
| 20 | bash /vagrant/tutorial-bootstrap.sh |
Carmelo Cascone | c5569c2 | 2018-04-18 10:09:15 +0900 | [diff] [blame] | 21 | EOF |
Carmelo Cascone | c5569c2 | 2018-04-18 10:09:15 +0900 | [diff] [blame] | 22 | fi |
| 23 | |
Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 24 | # Java 8 |
| 25 | apt-get install software-properties-common -y |
| 26 | add-apt-repository ppa:webupd8team/java -y |
| 27 | apt-get update |
Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 28 | |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 29 | DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade |
| 30 | |
Carmelo Cascone | ea2c110 | 2018-08-21 18:32:58 -0700 | [diff] [blame] | 31 | wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VER}/${BAZEL_DEB} |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 32 | 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] | 33 | apt-get -y --no-install-recommends install \ |
Carmelo Cascone | a1812ad | 2018-08-13 18:57:06 -0700 | [diff] [blame] | 34 | ./${BAZEL_DEB} \ |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 35 | avahi-daemon \ |
| 36 | bridge-utils \ |
| 37 | git \ |
| 38 | git-review \ |
| 39 | htop \ |
Carmelo Cascone | c5569c2 | 2018-04-18 10:09:15 +0900 | [diff] [blame] | 40 | oracle-java8-installer \ |
| 41 | oracle-java8-set-default \ |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 42 | python2.7 \ |
| 43 | python2.7-dev \ |
Carmelo Cascone | f11513d | 2018-01-16 00:31:14 -0800 | [diff] [blame] | 44 | valgrind \ |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 45 | zip unzip \ |
| 46 | tcpdump \ |
| 47 | vlan \ |
| 48 | ntp \ |
| 49 | vim nano emacs \ |
Charles Chan | 84431b9 | 2018-08-16 20:30:09 -0700 | [diff] [blame] | 50 | arping \ |
| 51 | gawk \ |
| 52 | texinfo \ |
| 53 | build-essential \ |
| 54 | iptables \ |
| 55 | automake \ |
| 56 | autoconf \ |
| 57 | libtool \ |
| 58 | isc-dhcp-server |
| 59 | |
| 60 | DEBIAN_FRONTEND=noninteractive apt-get -yq install wireshark |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 61 | |
Carmelo Cascone | a1812ad | 2018-08-13 18:57:06 -0700 | [diff] [blame] | 62 | rm -f ${BAZEL_DEB} |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 63 | |
| 64 | curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py |
| 65 | python2.7 get-pip.py --force-reinstall |
| 66 | rm -f get-pip.py |
Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 67 | |
Charles Chan | 84431b9 | 2018-08-16 20:30:09 -0700 | [diff] [blame] | 68 | pip install ipaddress |
| 69 | |
Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 70 | tee -a /etc/ssh/sshd_config <<EOF |
| 71 | |
| 72 | UseDNS no |
| 73 | EOF |
| 74 | |
| 75 | su sdn <<'EOF' |
| 76 | cd /home/sdn |
| 77 | bash /vagrant/user-bootstrap.sh |
| 78 | EOF |