Add a small init hook to fix linuxserver.io syntax errors

This commit is contained in:
2026-01-21 12:39:03 +01:00
parent 18594c772a
commit 3bfd9d5cdf
2 changed files with 29 additions and 0 deletions

View File

@@ -23,6 +23,9 @@ services:
# Log sources for fail2ban container # Log sources for fail2ban container
- /var/log:/var/log:ro - /var/log:/var/log:ro
- /var/log/httpd:/remotelogs/apache2: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 restart: unless-stopped

View File

@@ -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