From 85603193a2f4aae0a72c929446470edafd91d865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20H=C3=B6ll?= <33981934+nilshoell@users.noreply.github.com> Date: Wed, 2 Aug 2023 02:09:01 +0200 Subject: [PATCH] feat(setup): Add `fail2ban` sub-command `status ` (#3455) * Added status command to fail2ban setup script * Switched to `printf` for command output Co-authored-by: Casper * Update docs/content/config/security/fail2ban.md Co-authored-by: Casper --------- Co-authored-by: Casper --- docs/content/config/security/fail2ban.md | 6 ++++++ target/bin/fail2ban | 7 +++++++ target/bin/setup | 1 + 3 files changed, 14 insertions(+) diff --git a/docs/content/config/security/fail2ban.md b/docs/content/config/security/fail2ban.md index 0ea052a1..04e9a681 100644 --- a/docs/content/config/security/fail2ban.md +++ b/docs/content/config/security/fail2ban.md @@ -58,6 +58,12 @@ setup fail2ban the script will show all banned IP addresses. +To get a more detailed `status` view, run + +```bash +setup fail2ban status +``` + ### Managing Bans You can manage F2B with the `setup` script. The usage looks like this: diff --git a/target/bin/fail2ban b/target/bin/fail2ban index 2ae9deaf..8a76fcda 100755 --- a/target/bin/fail2ban +++ b/target/bin/fail2ban @@ -6,6 +6,7 @@ source /usr/local/bin/helpers/index.sh function __usage() { echo "Usage: ./setup.sh fail2ban [ ]" echo " ./setup.sh fail2ban log" + echo " ./setup.sh fail2ban status" } fail2ban-client ping &>/dev/null || _exit_with_error "Fail2ban not running" @@ -72,6 +73,12 @@ else cat /var/log/mail/fail2ban.log ;; + ( 'status' ) + for JAIL in "${JAILS[@]}"; do + printf '%s\n\n' "$(fail2ban-client status "${JAIL}" 2>&1)" + done + ;; + ( * ) __usage _exit_with_error "Unknown command '${1}'" diff --git a/target/bin/setup b/target/bin/setup index 29782b6f..ac0d6328 100755 --- a/target/bin/setup +++ b/target/bin/setup @@ -60,6 +60,7 @@ ${RED}[${ORANGE}SUB${RED}]${ORANGE}COMMANDS${RESET} setup fail2ban ${CYAN}ban${RESET} setup fail2ban ${CYAN}unban${RESET} setup fail2ban ${CYAN}log${RESET} + setup fail2ban ${CYAN}status${RESET} ${LBLUE}COMMAND${RESET} debug ${RED}:=${RESET} setup debug ${CYAN}fetchmail${RESET}