-
Notifications
You must be signed in to change notification settings - Fork 0
/
dispatch
executable file
·67 lines (61 loc) · 2.34 KB
/
dispatch
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
#!/bin/bash
# This hook installs the centos dependencies needed to run the charm.
set -e
# Source the os-release information into the env.
. /etc/os-release
if [ ! -f '.installed' ]
then
# Determine if we are running in centos or ubuntu, if centos
# provision the needed prereqs.
if [ $ID = 'centos' ]
then
# Determine the centos version and install prereqs accordingly
major=$(cat /etc/centos-release | tr -dc '0-9.'| cut -d \. -f1)
if [ $major = "7" ]
then
# Install yaml deps
yum -y install libyaml-devel
# Install python3 using yum (will install python3.6 on centos7)
if [ ! -e /usr/bin/python3 ]
then
echo "Running centos$major, installing prereqs."
# Install system python3
yum -y install epel-release
yum -y install python3
fi
# We need python3.8 to run cluster-agent.
# Install python3.8 from source.
if [ ! -e /usr/bin/python3.8 ]
then
yum install -y gcc zlib-devel bzip2 bzip2-devel readline-devel \
sqlite sqlite-devel openssl-devel tk-devel libffi-devel xz-devel wget
yum groupinstall "Development tools" -y
/bin/bash ./src/templates/install_python.sh
fi
else
echo "Running unsuppored version of centos: $major"
exit -1
fi
elif [ $ID = 'ubuntu' ]
then
# We are running an ubuntu os, so check for python and install the
# needed venv package or python3 from source, depending on what already
# exists on the system.
#
if [ ! -e /usr/bin/python3.8 ]
then
apt-get install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget \
curl llvm libncursesw5-dev xz-utils tk-dev \
libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
/bin/bash ./src/templates/install_python.sh
else
if [ ! -e /usr/bin/pip3 ]
then
apt-get install -y python3.8-venv
fi
fi
fi
touch .installed
fi
JUJU_DISPATCH_PATH="${JUJU_DISPATCH_PATH:-$0}" PYTHONPATH=lib:venv ./src/charm.py