Skip to content

Commit 19886fd

Browse files
authored
Merge pull request #459 from linuxserver/swag-auto-reload-s6v3
switch to hybrid (swag-auto-reload)
2 parents 8b39222 + afd0e52 commit 19886fd

File tree

11 files changed

+56
-0
lines changed

11 files changed

+56
-0
lines changed

root/etc/s6-overlay/s6-rc.d/init-mod-swag-auto-reload-add-package/dependencies.d/init-mods

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/with-contenv bash
2+
3+
if ! apk info 2>&1 | grep -q "inotify-tools"; then
4+
echo "**** Adding swag-auto-reload deps to package install list ****"
5+
echo "inotify-tools" >> /mod-repo-packages-to-install.list
6+
else
7+
echo "**** swag-auto-reload deps already installed, skipping ****"
8+
fi
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
oneshot
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/etc/s6-overlay/s6-rc.d/init-mod-swag-auto-reload-add-package/run

root/etc/s6-overlay/s6-rc.d/init-mods-package-install/dependencies.d/init-mod-swag-auto-reload-add-package

Whitespace-only changes.

root/etc/s6-overlay/s6-rc.d/svc-mod-swag-auto-reload/dependencies.d/init-services

Whitespace-only changes.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/with-contenv bash
2+
3+
DEFAULT_WATCH=( \
4+
/config/nginx/authelia-location.conf \
5+
/config/nginx/authelia-server.conf \
6+
/config/nginx/geoip2.conf \
7+
/config/nginx/ldap.conf \
8+
/config/nginx/nginx.conf \
9+
/config/nginx/proxy-confs \
10+
/config/nginx/proxy.conf \
11+
/config/nginx/site-confs \
12+
/config/nginx/ssl.conf \
13+
)
14+
15+
echo "MOD Auto-reload: Watching the following files/folders for changes"
16+
for i in ${DEFAULT_WATCH[@]}; do
17+
if [ -f "${i}" ] || [ -d "${i}" ]; then
18+
echo "${i}"
19+
ACTIVE_WATCH="${ACTIVE_WATCH} ${i}"
20+
fi
21+
done
22+
for i in $(echo "$WATCHLIST" | tr "|" " "); do
23+
if [ -f "${i}" ] || [ -d "${i}" ]; then
24+
echo "${i}"
25+
ACTIVE_WATCH="${ACTIVE_WATCH} ${i}"
26+
fi
27+
done
28+
29+
function wait_for_changes {
30+
inotifywait -rq \
31+
--event modify,move,create,delete \
32+
${ACTIVE_WATCH}
33+
}
34+
35+
while wait_for_changes; do
36+
if ! cat /etc/nginx/nginx.conf | grep "/config/nginx/nginx.conf"; then
37+
export NGINX_CONF="-c /config/nginx/nginx.conf"
38+
fi
39+
if /usr/sbin/nginx ${NGINX_CONF} -t; then
40+
echo "Changes to nginx config detected and the changes are valid, reloading nginx"
41+
/usr/sbin/nginx ${NGINX_CONF} -s reload
42+
else
43+
echo "Changes to nginx config detected but the changes are not valid, skipping nginx reload. Please fix your config."
44+
fi
45+
done
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
longrun

root/etc/s6-overlay/s6-rc.d/user/contents.d/init-mod-swag-auto-reload-add-package

Whitespace-only changes.

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

Whitespace-only changes.

0 commit comments

Comments
 (0)