From b5bb8f4594fc6573f9836539ef3ca5904a69c7cf Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Mon, 7 Mar 2022 19:54:44 +0100 Subject: [PATCH] update-ipblocklist: Add code to reload updated blocklists. Signed-off-by: Stefan Schantl --- src/scripts/update-ipblocklists | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/scripts/update-ipblocklists b/src/scripts/update-ipblocklists index 16ed3da383..96731d4499 100644 --- a/src/scripts/update-ipblocklists +++ b/src/scripts/update-ipblocklists @@ -69,6 +69,10 @@ unless (-e "${General::swroot}/red/active") { # Get all available blocklists. my @blocklists = &IPblocklist::get_blocklists(); +# Array to store successfully update blocklists. +# They need to be reloaded. +my @updated_blocklists = (); + # Gather the details, when a list got modified last time. my %modified = (); @@ -120,6 +124,21 @@ foreach my $blocklist (@blocklists) { } else { # Log successfull update. &_log_to_syslog(" Successfully updated $blocklist blocklist."); + + # Add the list to the array of updated blocklists. + push(@updated_blocklists, $blocklist); + } +} + +# Check if a blocklist has been updated and therefore needs to be reloaded. +if (@updated_blocklists) { + # Loop through the array. + foreach my $updated_blocklist (@updated_blocklists) { + # Get the blocklist file. + my $ipset_db_file = &IPblocklist::get_ipset_db_file($updated_blocklist); + + # Call safe system function to reload/update the blocklist. + &General::system("ipset", "restore", "-f", "$ipset_db_file"); } } -- 2.39.5