Watch the whole folder

Exclude sample and md
This commit is contained in:
Eric Nemchik
2022-09-22 14:42:52 +00:00
parent a5b5dbe4f5
commit a6de1bfc19
3 changed files with 5 additions and 46 deletions
+1 -4
View File
@@ -1,9 +1,6 @@
# Auto-reload - Docker mod for Nginx based images
This mod allows Nginx to be reloaded automatically whenever there are valid changes to the `*.conf` files in `/config/nginx` or any files in the following folders:
- /config/nginx/proxy-confs
- /config/nginx/site-confs
This mod allows Nginx to be reloaded automatically whenever there are new files, or valid changes to the files in `/config/nginx`.
In the container's docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:swag-auto-reload`
@@ -1,30 +1,11 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
DEFAULT_WATCH=()
mapfile -t DEFAULT_WATCH < <(find /config/nginx -type f -name '*.conf' -print)
DEFAULT_WATCH+=("/config/nginx/proxy-confs" "/config/nginx/site-confs")
# start with an empty array for active watch
ACTIVE_WATCH=()
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+=("${i}")
fi
done
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 \
"${ACTIVE_WATCH[@]}"
--excludei '\.(sample|md)' \
"/config/nginx"
}
while wait_for_changes; do
+2 -21
View File
@@ -1,30 +1,11 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
DEFAULT_WATCH=()
mapfile -t DEFAULT_WATCH < <(find /config/nginx -type f -name '*.conf' -print)
DEFAULT_WATCH+=("/config/nginx/proxy-confs" "/config/nginx/site-confs")
# start with an empty array for active watch
ACTIVE_WATCH=()
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+=("${i}")
fi
done
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 \
"${ACTIVE_WATCH[@]}"
--excludei '\.(sample|md)' \
"/config/nginx"
}
while wait_for_changes; do