Configure docker image
[ci-management.git] / packer / provision / docker.sh
1 #!/bin/bash
2
3 # vim: ts=4 sw=4 sts=4 et tw=72 :
4
5 rh_systems() {
6     # Assumes that python is already installed by basebuild
7
8     # Install dependencies for robotframework and robotframework-sshlibrary
9     yum install -y -q yum-utils unzip sshuttle nc libffi-devel openssl-devel
10
11     # Install docker
12     yum install -y docker supervisor bridge-utils
13     systemctl enable docker
14
15     # configure docker networking so that it does not conflict with LF
16     # internal networks
17     cat <<EOL > /etc/sysconfig/docker-network
18 # /etc/sysconfig/docker-network
19 DOCKER_NETWORK_OPTIONS='--bip=10.250.0.254/24'
20 EOL
21     # configure docker daemon to listen on port 5555 enabling remote
22     # managment
23     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
24
25     # docker group doesn't get created by default for some reason
26     groupadd docker
27 }
28
29 ubuntu_systems() {
30     # Assumes that python is already installed by basebuild
31
32     # Install dependencies for robotframework and robotframework-sshlibrary
33     apt install -y unzip sshuttle netcat libffi-dev libssl-dev
34
35     # Install docker
36     apt install -y docker.io
37 }
38
39 all_systems() {
40     echo 'No common distribution configuration to perform'
41 }
42
43 echo "---> Detecting OS"
44 ORIGIN=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')
45
46 case "${ORIGIN}" in
47     fedora|centos|redhat)
48         echo "---> RH type system detected"
49         rh_systems
50     ;;
51     ubuntu)
52         echo "---> Ubuntu system detected"
53         ubuntu_systems
54     ;;
55     *)
56         echo "---> Unknown operating system"
57     ;;
58 esac
59
60 # execute steps for all systems
61 all_systems