Files
docker-mods-uptime-kuma-tim…/root/etc/s6-overlay/s6-rc.d/svc-mod-swag-auto-reload/run
T
2022-09-01 09:13:56 -04:00

46 lines
1.3 KiB
Plaintext
Executable File

#!/usr/bin/with-contenv bash
DEFAULT_WATCH=( \
/config/nginx/authelia-location.conf \
/config/nginx/authelia-server.conf \
/config/nginx/geoip2.conf \
/config/nginx/ldap.conf \
/config/nginx/nginx.conf \
/config/nginx/proxy-confs \
/config/nginx/proxy.conf \
/config/nginx/site-confs \
/config/nginx/ssl.conf \
)
echo "MOD Auto-reload: Watching the following files/folders for changes"
for i in ${DEFAULT_WATCH[@]}; do
if [ -f "${i}" ] || [ -d "${i}" ]; then
echo "${i}"
ACTIVE_WATCH="${ACTIVE_WATCH} ${i}"
fi
done
for i in $(echo "$WATCHLIST" | tr "|" " "); do
if [ -f "${i}" ] || [ -d "${i}" ]; then
echo "${i}"
ACTIVE_WATCH="${ACTIVE_WATCH} ${i}"
fi
done
function wait_for_changes {
inotifywait -rq \
--event modify,move,create,delete \
${ACTIVE_WATCH}
}
while wait_for_changes; do
if ! cat /etc/nginx/nginx.conf | grep "/config/nginx/nginx.conf"; then
export NGINX_CONF="-c /config/nginx/nginx.conf"
fi
if /usr/sbin/nginx ${NGINX_CONF} -t; then
echo "Changes to nginx config detected and the changes are valid, reloading nginx"
/usr/sbin/nginx ${NGINX_CONF} -s reload
else
echo "Changes to nginx config detected but the changes are not valid, skipping nginx reload. Please fix your config."
fi
done