Merge "Install chrome to support ChromeDriver in CSIT"
[ci-management.git] / packer / provision / basebuild.sh
1 #!/bin/bash
2
3 # vim: ts=4 sw=4 sts=4 et tw=72 :
4
5 # force any errors to cause the script and job to end in failure
6 set -xeu -o pipefail
7
8 rh_systems() {
9     # Install python dependencies
10     yum install -y python-{devel,virtualenv,setuptools,pip}
11
12     # Build dependencies for Python packages
13     yum install -y openssl-devel mysql-devel gcc
14
15     # Autorelease support packages
16     yum install -y firefox python-tox xmlstarlet xvfb
17
18     # Install chrome to support ChromeDriver
19     cat <<EOF > /etc/yum.repos.d/google-chrome.repo
20 [google-chrome]
21 name=google-chrome
22 baseurl=http://dl.google.com/linux/chrome/rpm/stable/$basearch
23 enabled=1
24 gpgcheck=1
25 gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
26 EOF
27
28     yum -y update
29     yum -y install google-chrome-stable
30
31     # Additional libraries for Python ncclient
32     yum install -y libxml2 libxslt libxslt-devel libffi libffi-devel
33
34     # Packer builds happen from the centos flavor images
35     PACKERDIR=$(mktemp -d)
36     # disable double quote checking
37     # shellcheck disable=SC2086
38     cd $PACKERDIR
39     wget https://releases.hashicorp.com/packer/0.12.2/packer_0.12.2_linux_amd64.zip
40     unzip packer_0.12.2_linux_amd64.zip -d /usr/local/bin/
41     # rename packer to avoid conflicts with cracklib
42     mv /usr/local/bin/packer /usr/local/bin/packer.io
43
44     # cleanup from the installation
45     # disable double quote checking
46     # shellcheck disable=SC2086
47     rm -rf $PACKERDIR
48     # cleanup from previous install process
49     if [ -d /tmp/packer ]
50     then
51         rm -rf /tmp/packer
52     fi
53 }
54
55 ubuntu_systems() {
56     # Install python dependencies
57     apt-get install -y python-{dev,virtualenv,setuptools,pip}
58
59     # Build dependencies for Python packages
60     apt-get install -y libssl-dev libmysqlclient-dev gcc
61
62     # Autorelease support packages
63     apt-get install -y firefox python-tox xmlstarlet xvfb
64
65     # Install chrome to support ChromeDriver
66     wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
67     echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
68     apt-get update -y
69     apt-get install -y google-chrome-stable
70
71     # Additional libraries for Python ncclient
72     apt-get install -y wget unzip python-ncclient
73
74     # Add graphviz for documentation building
75     apt-get install -y graphviz
76
77     # Erlang and Rebar packages needed for DCAEGEN2
78     apt-get install -y libwxgtk3.0-0v5 libsctp1
79     wget https://packages.erlang-solutions.com/erlang/esl-erlang/FLAVOUR_1_general/esl-erlang_19.3.6-1~ubuntu~trusty_amd64.deb
80     dpkg -i esl-erlang_19.3.6-1~ubuntu~trusty_amd64.deb
81     apt-get install -y libwxbase3.0-0v5
82     apt-get -f install -y
83     git clone https://github.com/erlang/rebar3.git
84     cd rebar3
85     ./bootstrap
86     mv rebar3 /usr/bin/rebar3
87     cd ..
88 }
89
90 all_systems() {
91     echo 'No common distribution configuration to perform'
92 }
93
94 echo "---> Detecting OS"
95 ORIGIN=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')
96
97 case "${ORIGIN}" in
98     fedora|centos|redhat)
99         echo "---> RH type system detected"
100         rh_systems
101     ;;
102     ubuntu)
103         echo "---> Ubuntu system detected"
104         ubuntu_systems
105     ;;
106     *)
107         echo "---> Unknown operating system"
108     ;;
109 esac
110
111 # execute steps for all systems
112 all_systems