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" |
Carmelo Cascone | b0f45fe | 2018-10-11 08:31:59 -0700 | [diff] [blame] | 7 | BAZEL_SH="bazel-${BAZEL_VER}-installer-linux-x86_64.sh" |
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 | |
| 31 | 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] | 32 | apt-get -y --no-install-recommends install \ |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 33 | avahi-daemon \ |
| 34 | bridge-utils \ |
| 35 | git \ |
| 36 | git-review \ |
| 37 | htop \ |
Carmelo Cascone | c5569c2 | 2018-04-18 10:09:15 +0900 | [diff] [blame] | 38 | oracle-java8-installer \ |
| 39 | oracle-java8-set-default \ |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 40 | python2.7 \ |
| 41 | python2.7-dev \ |
Carmelo Cascone | f11513d | 2018-01-16 00:31:14 -0800 | [diff] [blame] | 42 | valgrind \ |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 43 | zip unzip \ |
| 44 | tcpdump \ |
| 45 | vlan \ |
| 46 | ntp \ |
| 47 | vim nano emacs \ |
Charles Chan | 84431b9 | 2018-08-16 20:30:09 -0700 | [diff] [blame] | 48 | arping \ |
| 49 | gawk \ |
| 50 | texinfo \ |
| 51 | build-essential \ |
| 52 | iptables \ |
| 53 | automake \ |
| 54 | autoconf \ |
| 55 | libtool \ |
| 56 | isc-dhcp-server |
| 57 | |
| 58 | DEBIAN_FRONTEND=noninteractive apt-get -yq install wireshark |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 59 | |
Carmelo Cascone | b0f45fe | 2018-10-11 08:31:59 -0700 | [diff] [blame] | 60 | # Install Bazel |
| 61 | wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VER}/${BAZEL_SH} |
| 62 | chmod +x ${BAZEL_SH} |
| 63 | ./${BAZEL_SH} |
| 64 | rm -f ${BAZEL_SH} |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 65 | |
Carmelo Cascone | b0f45fe | 2018-10-11 08:31:59 -0700 | [diff] [blame] | 66 | # 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] | 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 |
Charles Chan | 84431b9 | 2018-08-16 20:30:09 -0700 | [diff] [blame] | 70 | pip install ipaddress |
| 71 | |
Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 72 | tee -a /etc/ssh/sshd_config <<EOF |
| 73 | |
| 74 | UseDNS no |
| 75 | EOF |
| 76 | |
| 77 | su sdn <<'EOF' |
| 78 | cd /home/sdn |
| 79 | bash /vagrant/user-bootstrap.sh |
| 80 | EOF |