initial commit of file from CVS for smeserver-fail2ban on Sat Sep 7 19:53:17 AEST 2024
This commit is contained in:
27
root/etc/cron.daily/cleanup_fail2ban
Normal file
27
root/etc/cron.daily/cleanup_fail2ban
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use esmith::ConfigDB;
|
||||
|
||||
my $c = esmith::ConfigDB->open_ro;
|
||||
my $f = esmith::ConfigDB->open('fail2ban');
|
||||
my $f2b = $c->get('fail2ban');
|
||||
|
||||
exit (0) unless ($f2b);
|
||||
|
||||
my $bantime = $f2b->prop('BanTime') || '1800';
|
||||
my $mod = 0;
|
||||
|
||||
foreach my $ban ($f->get_all_by_prop( type => 'ban')){
|
||||
my $ts = $ban->prop('UnbanTimestamp') || time+$bantime;
|
||||
if ( $ts < time ){
|
||||
$ban->delete;
|
||||
$mod = 1;
|
||||
}
|
||||
}
|
||||
if ($mod == 1){
|
||||
die "An error occured during fail2ban rule update\n"
|
||||
unless (system('/sbin/e-smith/signal-event fail2ban-update') == 0);
|
||||
}
|
||||
exit (0);
|
Reference in New Issue
Block a user