mirror of https://github.com/jrbrtsn/ban2fail
Improvements to scripts, add cron script for report
This commit is contained in:
parent
b8cd7d1e97
commit
3fc95b33a0
|
@ -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
|
|
@ -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]
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue