Andrew Grimberg | ebc710a | 2017-01-30 12:59:38 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # vim: ts=4 sw=4 sts=4 et tw=72 : |
| 4 | |
Andrew Grimberg | 8ffb213 | 2017-02-07 10:48:06 -0800 | [diff] [blame] | 5 | # force any errors to cause the script and job to end in failure |
Andrew Grimberg | 7fb50b3 | 2017-02-07 10:54:58 -0800 | [diff] [blame] | 6 | set -xeu -o pipefail |
Andrew Grimberg | 8ffb213 | 2017-02-07 10:48:06 -0800 | [diff] [blame] | 7 | |
Andrew Grimberg | ebc710a | 2017-01-30 12:59:38 -0800 | [diff] [blame] | 8 | rh_systems() { |
| 9 | # Assumes that python is already installed by basebuild |
| 10 | |
| 11 | # Install dependencies for robotframework and robotframework-sshlibrary |
Andrew Grimberg | 8ffb213 | 2017-02-07 10:48:06 -0800 | [diff] [blame] | 12 | yum install -y yum-utils unzip sshuttle nc libffi-devel openssl-devel |
Andrew Grimberg | ebc710a | 2017-01-30 12:59:38 -0800 | [diff] [blame] | 13 | |
| 14 | # Install docker |
| 15 | yum install -y docker supervisor bridge-utils |
| 16 | systemctl enable docker |
| 17 | |
| 18 | # configure docker networking so that it does not conflict with LF |
| 19 | # internal networks |
| 20 | cat <<EOL > /etc/sysconfig/docker-network |
| 21 | # /etc/sysconfig/docker-network |
| 22 | DOCKER_NETWORK_OPTIONS='--bip=10.250.0.254/24' |
| 23 | EOL |
| 24 | # configure docker daemon to listen on port 5555 enabling remote |
| 25 | # managment |
| 26 | sed -i -e "s#='--selinux-enabled'#='--selinux-enabled -H unix:///var/run/docker.sock -H tcp://0.0.0.0:5555'#g" /etc/sysconfig/docker |
| 27 | |
| 28 | # docker group doesn't get created by default for some reason |
| 29 | groupadd docker |
Andrew Grimberg | ebc710a | 2017-01-30 12:59:38 -0800 | [diff] [blame] | 30 | } |
| 31 | |
Jessica Wagantall | 4699475 | 2017-11-06 18:13:14 -0800 | [diff] [blame] | 32 | ubuntu_docker_mtu_fix(){ |
| 33 | echo "---> Fixing docker's mtu settings" |
| 34 | systemctl stop docker |
Jessica Wagantall | 8d6333a | 2017-11-07 10:30:32 -0800 | [diff] [blame] | 35 | cat <<'EOL' > /etc/systemd/system/docker.service |
Jessica Wagantall | 4699475 | 2017-11-06 18:13:14 -0800 | [diff] [blame] | 36 | [Unit] |
| 37 | Description=Docker Application Container Engine |
| 38 | Documentation=https://docs.docker.com |
| 39 | After=network.target docker.socket |
| 40 | Requires=docker.socket |
| 41 | |
| 42 | [Service] |
| 43 | Type=notify |
| 44 | # the default is not to use systemd for cgroups because the delegate issues still |
| 45 | # exists and systemd currently does not support the cgroup feature set required |
| 46 | # for containers run by docker |
| 47 | ExecStart= |
| 48 | ExecStart=/usr/bin/dockerd --mtu 1454 -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock |
| 49 | ExecReload=/bin/kill -s HUP $MAINPID |
| 50 | # Having non-zero Limit*s causes performance problems due to accounting overhead |
| 51 | # in the kernel. We recommend using cgroups to do container-local accounting. |
| 52 | LimitNOFILE=infinity |
| 53 | LimitNPROC=infinity |
| 54 | LimitCORE=infinity |
| 55 | # Uncomment TasksMax if your systemd version supports it. |
| 56 | # Only systemd 226 and above support this version. |
| 57 | TasksMax=infinity |
| 58 | TimeoutStartSec=0 |
| 59 | # set delegate yes so that systemd does not reset the cgroups of docker containers |
| 60 | Delegate=yes |
| 61 | # kill only the docker process, not all processes in the cgroup |
| 62 | KillMode=process |
| 63 | |
| 64 | [Install] |
| 65 | WantedBy=multi-user.target |
| 66 | EOL |
| 67 | systemctl start docker |
| 68 | echo "---> Checking MTU" |
| 69 | docker network inspect bridge |
| 70 | echo "---> MTU set to 1454" |
| 71 | } |
| 72 | |
Andrew Grimberg | ebc710a | 2017-01-30 12:59:38 -0800 | [diff] [blame] | 73 | ubuntu_systems() { |
| 74 | # Assumes that python is already installed by basebuild |
| 75 | |
Jessica Wagantall | b95d13f | 2017-10-13 10:37:35 -0700 | [diff] [blame] | 76 | # Install Python3.6 |
| 77 | sudo add-apt-repository -y ppa:jonathonf/python-3.6 |
| 78 | sudo apt-get update |
Jessica Wagantall | 6226046 | 2017-10-19 08:51:03 -0700 | [diff] [blame] | 79 | sudo apt-get install -y python3.6 python3.6-dev |
Jessica Wagantall | b95d13f | 2017-10-13 10:37:35 -0700 | [diff] [blame] | 80 | |
Andrew Grimberg | ebc710a | 2017-01-30 12:59:38 -0800 | [diff] [blame] | 81 | # Install dependencies for robotframework and robotframework-sshlibrary |
| 82 | apt install -y unzip sshuttle netcat libffi-dev libssl-dev |
Jessica Wagantall | 8636649 | 2017-08-31 11:52:55 -0700 | [diff] [blame] | 83 | wget https://github.com/mozilla/geckodriver/releases/download/v0.18.0/geckodriver-v0.18.0-linux64.tar.gz |
| 84 | tar xvzf geckodriver-v0.18.0-linux64.tar.gz -C /usr/local/bin |
| 85 | export PATH=$PATH:/usr/local/bin |
Andrew Grimberg | ebc710a | 2017-01-30 12:59:38 -0800 | [diff] [blame] | 86 | |
| 87 | # Install docker |
| 88 | apt install -y docker.io |
Jessica Wagantall | 4699475 | 2017-11-06 18:13:14 -0800 | [diff] [blame] | 89 | |
| 90 | # Fixing Docker MTU settings |
| 91 | ubuntu_docker_mtu_fix |
Andrew Grimberg | ebc710a | 2017-01-30 12:59:38 -0800 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | all_systems() { |
Gary Wu | 86f7b4e | 2017-08-17 12:20:26 -0700 | [diff] [blame] | 95 | # Install docker-compose |
| 96 | curl -o /usr/local/bin/docker-compose -L "https://github.com/docker/compose/releases/download/1.15.0/docker-compose-$(uname -s)-$(uname -m)" |
| 97 | chmod +x /usr/local/bin/docker-compose |
| 98 | docker-compose -v |
Andrew Grimberg | ebc710a | 2017-01-30 12:59:38 -0800 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | echo "---> Detecting OS" |
| 102 | ORIGIN=$(facter operatingsystem | tr '[:upper:]' '[:lower:]') |
| 103 | |
| 104 | case "${ORIGIN}" in |
| 105 | fedora|centos|redhat) |
| 106 | echo "---> RH type system detected" |
| 107 | rh_systems |
| 108 | ;; |
| 109 | ubuntu) |
| 110 | echo "---> Ubuntu system detected" |
| 111 | ubuntu_systems |
| 112 | ;; |
| 113 | *) |
| 114 | echo "---> Unknown operating system" |
| 115 | ;; |
| 116 | esac |
| 117 | |
| 118 | # execute steps for all systems |
| 119 | all_systems |