Skip to content

Commit a6de1bf

Browse files
committed
Watch the whole folder
Exclude sample and md
1 parent a5b5dbe commit a6de1bf

File tree

3 files changed

+5
-46
lines changed
  • root/etc
    • s6-overlay/s6-rc.d/svc-mod-swag-auto-reload
    • services.d/inotify

3 files changed

+5
-46
lines changed

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# Auto-reload - Docker mod for Nginx based images
22

3-
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:
4-
5-
- /config/nginx/proxy-confs
6-
- /config/nginx/site-confs
3+
This mod allows Nginx to be reloaded automatically whenever there are new files, or valid changes to the files in `/config/nginx`.
74

85
In the container's docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:swag-auto-reload`
96

root/etc/s6-overlay/s6-rc.d/svc-mod-swag-auto-reload/run

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,11 @@
11
#!/usr/bin/with-contenv bash
22
# shellcheck shell=bash
33

4-
DEFAULT_WATCH=()
5-
mapfile -t DEFAULT_WATCH < <(find /config/nginx -type f -name '*.conf' -print)
6-
DEFAULT_WATCH+=("/config/nginx/proxy-confs" "/config/nginx/site-confs")
7-
8-
# start with an empty array for active watch
9-
ACTIVE_WATCH=()
10-
echo "MOD Auto-reload: Watching the following files/folders for changes"
11-
for i in "${DEFAULT_WATCH[@]}"; do
12-
if [ -f "${i}" ] || [ -d "${i}" ]; then
13-
echo "${i}"
14-
ACTIVE_WATCH+=("${i}")
15-
fi
16-
done
17-
for i in $(echo "${WATCHLIST}" | tr "|" " "); do
18-
if [ -f "${i}" ] || [ -d "${i}" ]; then
19-
echo "${i}"
20-
ACTIVE_WATCH+=("${i}")
21-
fi
22-
done
23-
244
function wait_for_changes {
255
inotifywait -rq \
266
--event modify,move,create,delete \
27-
"${ACTIVE_WATCH[@]}"
7+
--excludei '\.(sample|md)' \
8+
"/config/nginx"
289
}
2910

3011
while wait_for_changes; do

root/etc/services.d/inotify/run

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,11 @@
11
#!/usr/bin/with-contenv bash
22
# shellcheck shell=bash
33

4-
DEFAULT_WATCH=()
5-
mapfile -t DEFAULT_WATCH < <(find /config/nginx -type f -name '*.conf' -print)
6-
DEFAULT_WATCH+=("/config/nginx/proxy-confs" "/config/nginx/site-confs")
7-
8-
# start with an empty array for active watch
9-
ACTIVE_WATCH=()
10-
echo "MOD Auto-reload: Watching the following files/folders for changes"
11-
for i in "${DEFAULT_WATCH[@]}"; do
12-
if [ -f "${i}" ] || [ -d "${i}" ]; then
13-
echo "${i}"
14-
ACTIVE_WATCH+=("${i}")
15-
fi
16-
done
17-
for i in $(echo "${WATCHLIST}" | tr "|" " "); do
18-
if [ -f "${i}" ] || [ -d "${i}" ]; then
19-
echo "${i}"
20-
ACTIVE_WATCH+=("${i}")
21-
fi
22-
done
23-
244
function wait_for_changes {
255
inotifywait -rq \
266
--event modify,move,create,delete \
27-
"${ACTIVE_WATCH[@]}"
7+
--excludei '\.(sample|md)' \
8+
"/config/nginx"
289
}
2910

3011
while wait_for_changes; do

0 commit comments

Comments
 (0)