2021-01-24 23:53:43 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-02-14 09:56:35 +00:00
|
|
|
cp /etc/caddy/Caddyfile /etc/caddy/Caddyfile.default
|
2021-01-24 23:53:43 +00:00
|
|
|
|
2024-02-14 09:56:35 +00:00
|
|
|
while true; do
|
2021-01-24 23:53:43 +00:00
|
|
|
|
2024-02-14 09:56:35 +00:00
|
|
|
SEAHUB_IPS=$(dig +short $SEAHUB_HOSTNAME | sed -e 's/$/:8000/' | tr ' ' '\n' | sort | tr '\n' ' ')
|
|
|
|
SEAHUB_MEDIA_IPS=$(dig +short $SEAHUB_MEDIA_HOSTNAME | sed -e 's/$/:80/' | tr ' ' '\n' | sort | tr '\n' ' ')
|
2021-01-24 23:53:43 +00:00
|
|
|
|
2024-02-14 09:56:35 +00:00
|
|
|
cp /etc/caddy/Caddyfile.default /etc/caddy/Caddyfile.tmp
|
2021-01-24 23:53:43 +00:00
|
|
|
|
2024-02-14 09:56:35 +00:00
|
|
|
sed -i "s/$SEAHUB_HOSTNAME:8000/$(echo $SEAHUB_IPS)/g" /etc/caddy/Caddyfile.tmp
|
|
|
|
sed -i "s/$SEAHUB_MEDIA_HOSTNAME:80/$(echo $SEAHUB_MEDIA_IPS)/g" /etc/caddy/Caddyfile.tmp
|
2021-01-24 23:53:43 +00:00
|
|
|
|
2024-02-14 09:56:35 +00:00
|
|
|
if ! diff -q "/etc/caddy/Caddyfile" "/etc/caddy/Caddyfile.tmp"; then
|
|
|
|
rm -f /etc/caddy/Caddyfile
|
|
|
|
mv /etc/caddy/Caddyfile.tmp /etc/caddy/Caddyfile
|
|
|
|
echo "Applying new Caddyfile:"
|
|
|
|
cat /etc/caddy/Caddyfile
|
|
|
|
caddy reload --config /etc/caddy/Caddyfile
|
|
|
|
fi
|
2021-01-24 23:53:43 +00:00
|
|
|
|
2024-02-14 09:56:35 +00:00
|
|
|
sleep 10
|
|
|
|
|
|
|
|
done
|