mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2026-03-18 06:46:17 +00:00
refactor Authelia setup and configuration handling
This commit is contained in:
@@ -1,13 +1,6 @@
|
||||
FROM alpine:latest AS tools
|
||||
RUN apk add --no-cache inotify-tools
|
||||
|
||||
FROM authelia/authelia:latest
|
||||
|
||||
COPY --from=tools /usr/bin/inotifywait /usr/bin/inotifywait
|
||||
COPY --from=tools /usr/lib/libinotifytools* /usr/lib/
|
||||
|
||||
COPY entrypoint.sh /usr/local/bin/authelia-entrypoint.sh
|
||||
|
||||
RUN chmod +x /usr/local/bin/authelia-entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/authelia-entrypoint.sh"]
|
||||
|
||||
@@ -18,15 +18,27 @@ AUTHELIA_PID=$!
|
||||
sleep 3
|
||||
|
||||
echo "==> Watching ${CONFIG_PATH} for changes..."
|
||||
|
||||
# Function to safely get hash in minimal environments
|
||||
get_hash() {
|
||||
md5sum "$CONFIG_PATH" 2>/dev/null | awk '{print $1}' || echo "error"
|
||||
}
|
||||
|
||||
LAST_HASH=$(get_hash)
|
||||
|
||||
while true; do
|
||||
inotifywait -qq -e close_write,moved_to "${CONFIG_PATH}" 2>/dev/null || true
|
||||
sleep 2
|
||||
sleep 3
|
||||
CURRENT_HASH=$(get_hash)
|
||||
|
||||
echo "==> Configuration change detected, restarting Authelia..."
|
||||
kill "$AUTHELIA_PID" 2>/dev/null || true
|
||||
wait "$AUTHELIA_PID" 2>/dev/null || true
|
||||
if [ "$LAST_HASH" != "$CURRENT_HASH" ]; then
|
||||
echo "==> Configuration change detected, restarting Authelia..."
|
||||
LAST_HASH="$CURRENT_HASH"
|
||||
|
||||
kill "$AUTHELIA_PID" 2>/dev/null || true
|
||||
wait "$AUTHELIA_PID" 2>/dev/null || true
|
||||
|
||||
authelia --config "$CONFIG_PATH" &
|
||||
AUTHELIA_PID=$!
|
||||
echo "==> Authelia restarted with PID ${AUTHELIA_PID}"
|
||||
authelia --config "$CONFIG_PATH" &
|
||||
AUTHELIA_PID=$!
|
||||
echo "==> Authelia restarted with PID ${AUTHELIA_PID}"
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user