-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse_config.sh
executable file
·44 lines (35 loc) · 1.45 KB
/
parse_config.sh
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
# Parse the contents of containers.json into bash variables
CONFIG=$(cat /usr/local/etc/dhis/containers.json)
DHIS2_CONFIG_DIR="/usr/local/etc/dhis"
DHIS2_BIN_DIR="/usr/local/bin"
CLUSTER_ENABLED=false
LXD_VERSION="5.0/stable"
# Abort script on errors
#set -o errexit
# test for a valid json config
TESTCONFIG=$(echo $CONFIG |jq .) || { echo "Invalid containers.json"; exit 1; }
FQDN=$(echo $CONFIG | jq -r .fqdn)
EMAIL=$(echo $CONFIG | jq -r .email)
NETWORK=$(echo $CONFIG | jq -r .network)
MONITORING=$(echo $CONFIG | jq -r .monitoring)
APM=$(echo $CONFIG | jq -r .apm)
PROXY=$(echo $CONFIG | jq -r .proxy)
PROXY_IP=$(echo $CONFIG | jq -r '.containers[] | select(.name=="proxy") | .ip')
MUNIN_IP=$(echo $CONFIG | jq -r '.containers[] | select(.name=="monitor") | .ip')
ENCDEVICE=$(echo $CONFIG | jq -r .encrypted_device)
ENVIRONMENT=$(echo $CONFIG | jq ".environment")
CREDENTIALS_FILE="/usr/local/etc/dhis/.credentials.json"
if [[ ! $ENVIRONMENT == "null" ]]; then
ENVVARS=$(echo $ENVIRONMENT | jq -c "to_entries[]")
fi
# LXD config
LXDBR="lxdbr0"
DEFAULT_INTERFACE=$(ip route |grep default | awk '{print $5}')
#LXDBRADDR=$(lxc network get $LXDBR ipv4.address)
# ubuntu version for containers
GUESTOS="ubuntu"
GUESTOS_VERSION="$(echo $CONFIG | jq -r '.guestos_version // 20.04')"
# get configs for individual containers
CONTAINERS=$(echo $CONFIG | jq -c .containers[])
NAMES=$(echo $CONFIG | jq -r .containers[].name)
TYPES=$(echo $CONFIG | jq -r .containers[].type)