Improvements to scripts, add cron script for report

This commit is contained in:
john 2019-11-27 20:25:03 -05:00
parent b8cd7d1e97
commit 3fc95b33a0
3 changed files with 27 additions and 3 deletions

22
ban2fail-cron.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash -e
#
# JDR Wed 27 Nov 2019 08:16:00 PM EST
# The purpose of this script is to be run from a periodic
# cron job to send summary via email.
#
BAN2FAIL=/usr/local/bin/ban2fail
TRIES=
for (( TRIES= 0; TRIES < 10; ++TRIES )); do
$BAN2FAIL -s && break
sleep 1
done
exit 0

View File

@ -1,11 +1,11 @@
[Unit]
Description=Log file scanning and iptables filtering
ConditionPathExists=/etc/ban2fail/ban2fail.sh
ConditionPathExists=/usr/local/share/ban2fail/ban2fail.sh
[Service]
WorkingDirectory=/tmp
Type=simple
ExecStart=/etc/ban2fail/ban2fail.sh
ExecStart=/usr/local/share/ban2fail/ban2fail.sh
TimeoutSec=0
[Install]

View File

@ -41,7 +41,9 @@ while true; do
echo "Running $BAN2FAIL"
# Check for offenses
# If ban2fail failed, then pause to avoid DOS on CPU
$TIME $BAN2FAIL || sleep 1
while ! $TIME $BAN2FAIL; do
sleep 1
done
done < <(exec $INOTIFYWAIT -m $LOG_NAMES)