feat(setup): Add `fail2ban` sub-command `status <JAIL>` (#3455)

* Added status command to fail2ban setup script

* Switched to `printf` for command output

Co-authored-by: Casper <casperklein@users.noreply.github.com>

* Update docs/content/config/security/fail2ban.md

Co-authored-by: Casper <casperklein@users.noreply.github.com>

---------

Co-authored-by: Casper <casperklein@users.noreply.github.com>
This commit is contained in:
Nils Höll 2023-08-02 02:09:01 +02:00 committed by GitHub
parent da984e5696
commit 85603193a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 0 deletions

View File

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

View File

@ -6,6 +6,7 @@ source /usr/local/bin/helpers/index.sh
function __usage() {
echo "Usage: ./setup.sh fail2ban [<ban|unban> <IP>]"
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}'"

View File

@ -60,6 +60,7 @@ ${RED}[${ORANGE}SUB${RED}]${ORANGE}COMMANDS${RESET}
setup fail2ban ${CYAN}ban${RESET} <IP>
setup fail2ban ${CYAN}unban${RESET} <IP>
setup fail2ban ${CYAN}log${RESET}
setup fail2ban ${CYAN}status${RESET}
${LBLUE}COMMAND${RESET} debug ${RED}:=${RESET}
setup debug ${CYAN}fetchmail${RESET}