forked from freifunkMUC/wgkex
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint
executable file
·53 lines (47 loc) · 959 Bytes
/
entrypoint
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
#!/bin/bash
set -e
: "${WGKEX_DOMAINS:=ffmuc_muc_cty, ffmuc_muc_nord, ffmuc_muc_ost, ffmuc_muc_sued, ffmuc_muc_west, ffmuc_welt, ffwert_city}"
: "${WGKEX_DOMAIN_PREFIXES:=ffmuc_, ffdon_, ffwert_}"
: "${WGKEX_DEBUG:=DEBUG}"
: "${MQTT_BROKER_URL:=mqtt}"
: "${MQTT_BROKER_PORT:=1883}"
: "${MQTT_USERNAME:=}"
: "${MQTT_PASSWORD:=}"
: "${MQTT_KEEPALIVE:=5}"
: "${MQTT_TLS:=False}"
mk_config() {
if [ ! -e /etc/wgkex.yaml ] ; then
(
echo "domains:"
IFS=", "
for i in $WGKEX_DOMAINS; do
echo " - $i"
done
echo "domain_prefixes:"
for i in $WGKEX_DOMAIN_PREFIXES; do
echo " - $i"
done
cat <<EOF
log_level: $WGKEX_DEBUG
mqtt:
broker_url: $MQTT_BROKER_URL
broker_port: $MQTT_BROKER_PORT
username: $MQTT_USERNAME
password: $MQTT_PASSWORD
keepalive: $MQTT_KEEPALIVE
tls: $MQTT_TLS
EOF
unset IFS
) > /etc/wgkex.yaml
fi
}
mk_config
case "$1" in
broker)
exec ./wgkex/broker/app
;;
worker)
exec ./wgkex/worker/app
;;
esac
exec "$@"