From d83f92e0077ee4992d522bb196366f27b8dc6f78 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Thu, 22 Sep 2022 14:52:32 +0000 Subject: [PATCH] Fix logic --- .../s6-overlay/s6-rc.d/svc-mod-swag-auto-reload/run | 12 +++++++++++- root/etc/services.d/inotify/run | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/svc-mod-swag-auto-reload/run b/root/etc/s6-overlay/s6-rc.d/svc-mod-swag-auto-reload/run index 06d3b88..1e92149 100755 --- a/root/etc/s6-overlay/s6-rc.d/svc-mod-swag-auto-reload/run +++ b/root/etc/s6-overlay/s6-rc.d/svc-mod-swag-auto-reload/run @@ -1,11 +1,21 @@ #!/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)' \ - "/config/nginx" + "${ACTIVE_WATCH[@]}" } while wait_for_changes; do diff --git a/root/etc/services.d/inotify/run b/root/etc/services.d/inotify/run index 06d3b88..1e92149 100755 --- a/root/etc/services.d/inotify/run +++ b/root/etc/services.d/inotify/run @@ -1,11 +1,21 @@ #!/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)' \ - "/config/nginx" + "${ACTIVE_WATCH[@]}" } while wait_for_changes; do