mirror of
https://github.com/jrbrtsn/ban2fail
synced 2024-06-16 03:48:03 +00:00
Improvements to scripts, add cron script for report
This commit is contained in:
parent
b8cd7d1e97
commit
3fc95b33a0
22
ban2fail-cron.sh
Executable file
22
ban2fail-cron.sh
Executable 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
|
@ -1,11 +1,11 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Log file scanning and iptables filtering
|
Description=Log file scanning and iptables filtering
|
||||||
ConditionPathExists=/etc/ban2fail/ban2fail.sh
|
ConditionPathExists=/usr/local/share/ban2fail/ban2fail.sh
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
WorkingDirectory=/tmp
|
WorkingDirectory=/tmp
|
||||||
Type=simple
|
Type=simple
|
||||||
ExecStart=/etc/ban2fail/ban2fail.sh
|
ExecStart=/usr/local/share/ban2fail/ban2fail.sh
|
||||||
TimeoutSec=0
|
TimeoutSec=0
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
@ -41,7 +41,9 @@ while true; do
|
|||||||
echo "Running $BAN2FAIL"
|
echo "Running $BAN2FAIL"
|
||||||
# Check for offenses
|
# Check for offenses
|
||||||
# If ban2fail failed, then pause to avoid DOS on CPU
|
# 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)
|
done < <(exec $INOTIFYWAIT -m $LOG_NAMES)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user