2023-08-24 22:24:47 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
2023-08-24 22:46:35 +08:00
|
|
|
# Only start container if nextcloud is accessible
|
2023-09-28 03:27:24 +08:00
|
|
|
while ! nc -z "$NEXTCLOUD_HOST" 9001; do
|
2023-08-24 22:46:35 +08:00
|
|
|
echo "Waiting for Nextcloud to start..."
|
|
|
|
sleep 5
|
|
|
|
done
|
|
|
|
|
2023-08-24 22:24:47 +08:00
|
|
|
set -x
|
2023-11-06 21:16:54 +08:00
|
|
|
IPv4_ADDRESS_NC="$(dig nextcloud-aio-nextcloud IN A +short +search | grep '^[0-9.]\+$' | sort | head -n1)"
|
2023-08-30 21:13:08 +08:00
|
|
|
HAPROXYFILE="$(sed "s|NC_IPV4_PLACEHOLDER|$IPv4_ADDRESS_NC|" /haproxy.cfg)"
|
|
|
|
echo "$HAPROXYFILE" > /tmp/haproxy.cfg
|
2023-08-24 22:24:47 +08:00
|
|
|
|
2023-11-06 21:16:54 +08:00
|
|
|
IPv6_ADDRESS_NC="$(dig nextcloud-aio-nextcloud AAAA +short +search | grep '^[0-9a-f:]\+$' | sort | head -n1)"
|
2023-08-30 22:58:32 +08:00
|
|
|
if [ -n "$IPv6_ADDRESS_NC" ]; then
|
|
|
|
HAPROXYFILE="$(sed "s|NC_IPV6_PLACEHOLDER|$IPv6_ADDRESS_NC|" /tmp/haproxy.cfg)"
|
|
|
|
else
|
|
|
|
HAPROXYFILE="$(sed "s# || { src NC_IPV6_PLACEHOLDER }##g" /tmp/haproxy.cfg)"
|
|
|
|
fi
|
2023-08-30 21:13:08 +08:00
|
|
|
echo "$HAPROXYFILE" > /tmp/haproxy.cfg
|
2023-08-24 22:24:47 +08:00
|
|
|
set +x
|
|
|
|
|
2023-08-30 21:13:08 +08:00
|
|
|
haproxy -f /tmp/haproxy.cfg -db
|