mirror of
https://github.com/swissmakers/fail2ban-ui.git
synced 2026-04-11 13:47:05 +02:00
Add a small init hook to fix linuxserver.io syntax errors
This commit is contained in:
@@ -23,6 +23,9 @@ services:
|
||||
# Log sources for fail2ban container
|
||||
- /var/log:/var/log:ro
|
||||
- /var/log/httpd:/remotelogs/apache2:ro
|
||||
|
||||
# New: custom init + service hooks (read-only is recommended)
|
||||
- ./fail2ban-ssh-custom-cont-init.d/20-fix-jail-enabled-key:/custom-cont-init.d/20-fix-jail-enabled-key:ro,z
|
||||
restart: unless-stopped
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
set -euo pipefail
|
||||
|
||||
fix_file() {
|
||||
local f="$1"
|
||||
[ -f "$f" ] || return 0
|
||||
|
||||
# Only touch the file if it actually contains the wrong key at line start
|
||||
if grep -Eq '^[[:space:]]*enable[[:space:]]*=' "$f"; then
|
||||
echo "[custom-init] fixing key 'enable' -> 'enabled' in: $f"
|
||||
cp -a "$f" "${f}.bak.$(date +%s)" || true
|
||||
|
||||
# BusyBox/Alpine-compatible sed (basic regex)
|
||||
# Preserves indentation and spacing around '='
|
||||
sed -i \
|
||||
's/^\([[:space:]]*\)enable\([[:space:]]*=\)/\1enabled\2/' \
|
||||
"$f"
|
||||
fi
|
||||
}
|
||||
|
||||
# These paths are typically the same in LSIO (since /etc/fail2ban -> /config/fail2ban),
|
||||
# but we list both to be safe in case of future changes.
|
||||
fix_file /etc/fail2ban/jail.d/dropbear.conf
|
||||
fix_file /etc/fail2ban/jail.d/selinux-ssh.conf
|
||||
fix_file /config/fail2ban/jail.d/dropbear.conf
|
||||
fix_file /config/fail2ban/jail.d/selinux-ssh.conf
|
||||
Reference in New Issue
Block a user