-
Notifications
You must be signed in to change notification settings - Fork 12
/
docker_entrypoint.sh
101 lines (96 loc) · 3.03 KB
/
docker_entrypoint.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
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
#!/bin/bash
JUICEPASSPROXY="/juicepassproxy/juicepassproxy.py"
function logger() {
if [ "${1^^}" != "DEBUG" ] || ($DEBUG && [ "${1^^}" = "DEBUG" ]); then
printf "%-20s %-9s [entrypoint.sh] %s\n" "$(date +'%Y-%m-%d %H:%M:%S')" "${1^^}" "${2}"
fi
}
echo "--------------------------------"
logger INFO "Starting JuicePass Proxy"
echo ""
JPP_STRING="python3 ${JUICEPASSPROXY}"
logger INFO "Docker Environment Variables:"
if [[ ! -z "${DEVICE_NAME}" ]]; then
logger INFO "DEVICE_NAME: ${DEVICE_NAME}"
JPP_STRING+=" --name ${DEVICE_NAME}"
fi
if [[ ! -z "${JUICEBOX_HOST}" ]]; then
logger INFO "JUICEBOX_HOST: ${JUICEBOX_HOST}"
JPP_STRING+=" --juicebox_host ${JUICEBOX_HOST}"
fi
if [[ ! -z "${JUICEBOX_ID}" ]]; then
logger INFO "JUICEBOX_ID: ${JUICEBOX_ID}"
JPP_STRING+=" --juicebox_id ${JUICEBOX_ID}"
fi
if [[ ! -z "${LOCAL_IP}" ]]; then
logger INFO "LOCAL_IP: ${LOCAL_IP}"
JPP_STRING+=" --local_ip ${LOCAL_IP}"
elif [[ ! -z "${SRC}" ]]; then
logger INFO "LOCAL_IP: ${SRC}"
JPP_STRING+=" --local_ip ${SRC}"
fi
if [[ ! -z "${LOCAL_PORT}" ]]; then
logger INFO "LOCAL_PORT: ${LOCAL_PORT}"
JPP_STRING+=" --local_port ${LOCAL_PORT}"
fi
if [[ ! -z "${ENELX_IP}" ]]; then
logger INFO "ENELX_IP: ${ENELX_IP}"
JPP_STRING+=" --enelx_ip ${ENELX_IP}"
elif [[ ! -z "${DST}" ]]; then
logger INFO "ENELX_IP: ${DST}"
JPP_STRING+=" --enelx_ip ${DST}"
fi
if [[ ! -z "${MQTT_HOST}" ]]; then
logger INFO "MQTT_HOST: ${MQTT_HOST}"
JPP_STRING+=" --mqtt_host ${MQTT_HOST}"
fi
if [[ ! -z "${MQTT_PORT}" ]]; then
logger INFO "MQTT_PORT: ${MQTT_PORT}"
JPP_STRING+=" --mqtt_port ${MQTT_PORT}"
fi
if [[ ! -z "${MQTT_USER}" ]]; then
logger INFO "MQTT_USER: ${MQTT_USER}"
JPP_STRING+=" --mqtt_user ${MQTT_USER}"
fi
if [[ ! -z "${MQTT_PASS}" ]]; then
logger INFO "MQTT_PASS: $(echo ${MQTT_PASS} | sed -E 's/./*/g')"
JPP_STRING+=" --mqtt_password ${MQTT_PASS}"
fi
if [[ ! -z "${MQTT_DISCOVERY_PREFIX}" ]]; then
logger INFO "MQTT_DISCOVERY_PREFIX: ${MQTT_DISCOVERY_PREFIX}"
JPP_STRING+=" --mqtt_discovery_prefix ${MQTT_DISCOVERY_PREFIX}"
fi
if [[ ! -z "${JPP_HOST}" ]]; then
logger INFO "JPP_HOST: ${JPP_HOST}"
JPP_STRING+=" --juicepass_proxy_host ${JPP_HOST}"
fi
if [[ ! -z "${TELNET_TIMEOUT}" ]]; then
logger INFO "TELNET_TIMEOUT: ${TELNET_TIMEOUT}"
JPP_STRING+=" --telnet_timeout ${TELNET_TIMEOUT}"
fi
JPP_STRING+=" --config_loc /config"
JPP_STRING+=" --log_loc /log"
logger INFO "DEBUG: ${DEBUG}"
if $DEBUG; then
JPP_STRING+=" --debug"
fi
if [[ -v UPDATE_UDPC ]] && $UPDATE_UDPC; then
JPP_STRING+=" --update_udpc"
logger INFO "UPDATE_UDPC: true"
else
logger INFO "UPDATE_UDPC: false"
fi
if [[ -v IGNORE_ENELX ]] && $IGNORE_ENELX; then
JPP_STRING+=" --ignore_enelx"
logger INFO "IGNORE_ENELX: true"
else
logger INFO "IGNORE_ENELX: false"
fi
if [[ -v EXPERIMENTAL ]] && $EXPERIMENTAL; then
JPP_STRING+=" --experimental"
logger INFO "EXPERIMENTAL: true"
else
logger INFO "EXPERIMENTAL: false"
fi
logger DEBUG "COMMAND: $(echo ${JPP_STRING} | sed -E 's/(.* --mqtt_password )([\"]?[a-zA-Z0-9_\?\*\^\&\#\@\!]+[\"]?)/\1*****/g')"
exec ${JPP_STRING}