]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
update-ipblocklist: Add code to reload updated blocklists.
authorStefan Schantl <stefan.schantl@ipfire.org>
Mon, 7 Mar 2022 18:54:44 +0000 (19:54 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Thu, 7 Jul 2022 15:26:14 +0000 (17:26 +0200)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
src/scripts/update-ipblocklists

index 16ed3da383194069c57d4b4e59e870eb9a3afe7f..96731d44996d7e0627f4feed2b6eaff64f936683 100644 (file)
@@ -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("<INFO> 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");
        }
 }