mirror of
https://github.com/nextcloud/all-in-one.git
synced 2026-05-28 14:30:13 +00:00
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: szaimen <42591237+szaimen@users.noreply.github.com>
33 lines
1008 B
Bash
33 lines
1008 B
Bash
#!/bin/sh
|
|
# SPDX-FileCopyrightText: 2023 Nextcloud GmbH <https://nextcloud.com>
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
if [ "$AIO_LOG_LEVEL" = 'debug' ]; then
|
|
set -x
|
|
fi
|
|
|
|
# Only start container if nextcloud is accessible
|
|
while ! nc -z "$NEXTCLOUD_HOST" 9001; do
|
|
echo "Waiting for Nextcloud to start..."
|
|
sleep 5
|
|
done
|
|
|
|
set -x
|
|
IPv4_ADDRESS_NC="$(dig nextcloud-aio-nextcloud IN A +short +search | grep '^[0-9.]\+$' | sort | head -n1)"
|
|
HAPROXYFILE="$(sed "s|NC_IPV4_PLACEHOLDER|$IPv4_ADDRESS_NC|" /haproxy.cfg)"
|
|
echo "$HAPROXYFILE" > /tmp/haproxy.cfg
|
|
|
|
IPv6_ADDRESS_NC="$(dig nextcloud-aio-nextcloud AAAA +short +search | grep '^[0-9a-f:]\+$' | sort | head -n1)"
|
|
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
|
|
echo "$HAPROXYFILE" > /tmp/haproxy.cfg
|
|
if [ "$AIO_LOG_LEVEL" != 'debug' ]; then
|
|
set +x
|
|
fi
|
|
|
|
haproxy -f /tmp/haproxy.cfg -db
|