@@ -15,9 +15,17 @@ if [ ! -f "/haproxy.cfg" ]; then
15
15
fi
16
16
17
17
if [ -n " $NC_HAPROXY_PASSWORD_FILE " ]; then
18
- NC_HAPROXY_PASSWORD=$( mkpasswd -m sha-256 < " $NC_HAPROXY_PASSWORD_FILE " )
19
- else
18
+ if [ -s " $NC_HAPROXY_PASSWORD_FILE " ]; then
19
+ NC_HAPROXY_PASSWORD=$( mkpasswd -m sha-256 < " $NC_HAPROXY_PASSWORD_FILE " )
20
+ else
21
+ echo " Error: NC_HAPROXY_PASSWORD_FILE is specified but is empty."
22
+ exit 1
23
+ fi
24
+ elif [ -n " $NC_HAPROXY_PASSWORD " ]; then
20
25
NC_HAPROXY_PASSWORD=$( echo " $NC_HAPROXY_PASSWORD " | mkpasswd -m sha-256)
26
+ else
27
+ echo " Error: Either NC_HAPROXY_PASSWORD_FILE or NC_HAPROXY_PASSWORD must be set and contain a password."
28
+ exit 1
21
29
fi
22
30
23
31
export NC_HAPROXY_PASSWORD
@@ -26,14 +34,14 @@ if [ ! -f "/haproxy.cfg" ]; then
26
34
envsubst < /haproxy_ex_apps.cfg.template > /haproxy_ex_apps.cfg
27
35
28
36
if [ -f " /certs/cert.pem" ]; then
29
- EX_APPS_COUNT_PADDED=$( printf " %03d" " $EX_APPS_COUNT " )
30
- sed -i " s|BIND_ADDRESS_PLACEHOLDER|bind $BIND_ADDRESS :$HAPROXY_PORT v4v6 ssl crt /certs/cert.pem|" /haproxy.cfg
31
- sed -i " s|BIND_ADDRESS_PLACEHOLDER|bind $BIND_ADDRESS :23000-23$EX_APPS_COUNT_PADDED v4v6 ssl crt /certs/cert.pem|" /haproxy_ex_apps.cfg
32
- sed -i " s|EX_APPS_NET_PLACEHOLDER|$EX_APPS_NET |" /haproxy_ex_apps.cfg
33
- # Chmod certs to be accessible by haproxy
34
- chmod 644 /certs/cert.pem
37
+ EX_APPS_COUNT_PADDED=$( printf " %03d" " $EX_APPS_COUNT " )
38
+ sed -i " s|BIND_ADDRESS_PLACEHOLDER|bind $BIND_ADDRESS :$HAPROXY_PORT v4v6 ssl crt /certs/cert.pem|" /haproxy.cfg
39
+ sed -i " s|BIND_ADDRESS_PLACEHOLDER|bind $BIND_ADDRESS :23000-23$EX_APPS_COUNT_PADDED v4v6 ssl crt /certs/cert.pem|" /haproxy_ex_apps.cfg
40
+ sed -i " s|EX_APPS_NET_PLACEHOLDER|$EX_APPS_NET |" /haproxy_ex_apps.cfg
41
+ # Chmod certs to be accessible by haproxy
42
+ chmod 644 /certs/cert.pem
35
43
else
36
- sed -i " s|BIND_ADDRESS_PLACEHOLDER|bind $BIND_ADDRESS :$HAPROXY_PORT v4v6|" /haproxy.cfg
44
+ sed -i " s|BIND_ADDRESS_PLACEHOLDER|bind $BIND_ADDRESS :$HAPROXY_PORT v4v6|" /haproxy.cfg
37
45
fi
38
46
else
39
47
echo " HaProxy config already present."
49
57
cat /haproxy.cfg
50
58
haproxy -f /haproxy.cfg -db
51
59
fi
60
+
52
61
echo " HaProxy quit unexpectedly"
53
62
exit 1
0 commit comments