mirror of
https://github.com/swissmakers/fail2ban-ui.git
synced 2026-04-11 13:47:05 +02:00
27 lines
883 B
Plaintext
27 lines
883 B
Plaintext
|
|
#!/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
|