swag-auto-reload update/add workflows

This commit is contained in:
aptalca
2023-05-18 14:45:22 -04:00
parent 5ba357719b
commit 350917a837
6 changed files with 63 additions and 87 deletions
-3
View File
@@ -1,3 +0,0 @@
#!/usr/bin/with-contenv bash
apk add --no-cache inotify-tools
-32
View File
@@ -1,32 +0,0 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
echo "MOD Auto-reload: Watching the following files/folders for changes (excluding .sample and .md files):"
echo "/config/nginx"
ACTIVE_WATCH=("/config/nginx")
for i in $(echo "${WATCHLIST}" | tr "|" " "); do
if [ -f "${i}" ] || [ -d "${i}" ]; then
echo "${i}"
ACTIVE_WATCH+=("${i}")
fi
done
function wait_for_changes {
inotifywait -rq \
--event modify,move,create,delete \
--excludei '\.(sample|md)' \
"${ACTIVE_WATCH[@]}"
}
while wait_for_changes; do
NGINX_CONF=()
if ! grep -q "/config/nginx/nginx.conf" /etc/nginx/nginx.conf; then
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