changeset 6533:0f61d13ebbde

mod_firewall: Update module status when scripts succeed/fail to load
author Matthew Wild <mwild1@gmail.com>
date Wed, 06 May 2026 15:41:56 +0100
parents ac6f0db675aa
children 5aeefc2251d4
files mod_firewall/mod_firewall.lua
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_firewall/mod_firewall.lua	Mon May 04 23:57:07 2026 +0200
+++ b/mod_firewall/mod_firewall.lua	Wed May 06 15:41:56 2026 +0100
@@ -713,6 +713,7 @@
 	end
 	loaded_scripts[script] = { last_modified = last_modified, events_hooked = events_hooked };
 	module:log("debug", "Loaded %s", script);
+	return true;
 end
 
 --COMPAT w/0.9 (no module:unhook()!)
@@ -743,14 +744,19 @@
 	local wanted_scripts = script_list / resolve_script_path;
 	local currently_loaded = set.new(it.to_array(it.keys(loaded_scripts)));
 	local scripts_to_unload = currently_loaded - wanted_scripts;
+	local n_wanted, n_loaded = 0, 0;
 	for script in wanted_scripts do
+		n_wanted = n_wanted + 1;
 		-- If the script is already loaded, this is fine - it will
 		-- reload the script for us if the file has changed
-		load_script(script);
+		if load_script(script) then
+			n_loaded = n_loaded + 1;
+		end
 	end
 	for script in scripts_to_unload do
 		unload_script(script);
 	end
+	module:log_status(n_wanted == n_loaded and "info" or "warn", "Loaded %d of %d scripts", n_loaded, n_wanted);
 end
 
 function module.load()