summaryrefslogtreecommitdiffstats
path: root/packer/provision/basebuild.sh
blob: 9e20664a5566f3c40d93f449dd42511733e99833 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash

# vim: ts=4 sw=4 sts=4 et tw=72 :

# force any errors to cause the script and job to end in failure
set -xeu -o pipefail

rh_systems() {
    # Install python dependencies
    yum install -y python-{devel,virtualenv,setuptools,pip}

    # Build dependencies for Python packages
    yum install -y openssl-devel mysql-devel gcc

    # Autorelease support packages
    yum install -y firefox python-tox xmlstarlet xvfb crudini

    # Install chrome to support ChromeDriver
    cat << EOF > /etc/yum.repos.d/google-chrome.repo
[google-chrome]
name=google-chrome - \$basearch
baseurl=http://dl.google.com/linux/chrome/rpm/stable/\$basearch
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
EOF

    yum -y update
    yum -y install google-chrome-stable

    # Additional libraries for Python ncclient
    yum install -y libxml2 libxslt libxslt-devel libffi libffi-devel

    # Packer builds happen from the centos flavor images
    PACKERDIR=$(mktemp -d)
    # disable double quote checking
    # shellcheck disable=SC2086
    cd $PACKERDIR
    wget https://releases.hashicorp.com/packer/0.12.2/packer_0.12.2_linux_amd64.zip
    unzip packer_0.12.2_linux_amd64.zip -d /usr/local/bin/
    # rename packer to avoid conflicts with cracklib
    mv /usr/local/bin/packer /usr/local/bin/packer.io

    # cleanup from the installation
    # disable double quote checking
    # shellcheck disable=SC2086
    rm -rf $PACKERDIR
    # cleanup from previous install process
    if [ -d /tmp/packer ]
    then
        rm -rf /tmp/packer
    fi
}

ubuntu_systems() {
    # Install python3.6
    sudo add-apt-repository -y ppa:jonathonf/python-3.6
    sudo apt-get update
    sudo apt-get install -y python3.6 python3.6-dev

    # Install python dependencies
    apt-get install -y python-{dev,virtualenv,setuptools,pip}

    # Build dependencies for Python packages
    apt-get install -y libssl-dev libmysqlclient-dev gcc

    # Autorelease support packages
    apt-get install -y firefox python-tox xmlstarlet xvfb crudini

    # Install chrome to support ChromeDriver
    wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
    echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
    apt-get update -y
    apt-get install -y google-chrome-stable

    # Additional libraries for Python ncclient
    apt-get install -y wget unzip python-ncclient

    # Add graphviz for documentation building
    apt-get install -y graphviz

    # Erlang and Rebar packages needed for DCAEGEN2
    apt-get install -y libwxgtk3.0-0v5 libsctp1
    wget https://packages.erlang-solutions.com/erlang/esl-erlang/FLAVOUR_1_general/esl-erlang_19.3.6-1~ubuntu~trusty_amd64.deb
    dpkg -i esl-erlang_19.3.6-1~ubuntu~trusty_amd64.deb
    apt-get install -y libwxbase3.0-0v5
    apt-get -f install -y
    git clone https://github.com/erlang/rebar3.git
    cd rebar3
    ./bootstrap
    mv rebar3 /usr/bin/rebar3
    cd ..
}

all_systems() {
    echo 'No common distribution configuration to perform'
}

echo "---> Detecting OS"
ORIGIN=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')

case "${ORIGIN}" in
    fedora|centos|redhat)
        echo "---> RH type system detected"
        rh_systems
    ;;
    ubuntu)
        echo "---> Ubuntu system detected"
        ubuntu_systems
    ;;
    *)
        echo "---> Unknown operating system"
    ;;
esac

# execute steps for all systems
all_systems