From 7b8f6e3c3e8be2470787408cc61d1919bbac0c4b Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 15 Nov 2024 15:52:37 +0100 Subject: mod_admin_shell: Report when a module is already loaded Hopefully less confusing than "Module loaded onto 0 hosts" --- plugins/mod_admin_shell.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'plugins') diff --git a/plugins/mod_admin_shell.lua b/plugins/mod_admin_shell.lua index 02f7c559..0b8d3c43 100644 --- a/plugins/mod_admin_shell.lua +++ b/plugins/mod_admin_shell.lua @@ -631,6 +631,7 @@ describe_command [[module:load(module, host) - Load the specified module on the function def_env.module:load(name, hosts) hosts = get_hosts_with_module(hosts); + local already_loaded = set.new(); -- Load the module for each host local ok, err, count, mod = true, nil, 0; for host in hosts do @@ -655,12 +656,17 @@ function def_env.module:load(name, hosts) self.session.print("Note: Module will not be loaded after restart unless enabled in configuration"); end end + else + already_loaded:add(host); end end if not ok then return ok, "Last error: "..tostring(err); end + if already_loaded == hosts then + return ok, "Module already loaded"; + end return ok, "Module loaded onto "..count.." host"..(count ~= 1 and "s" or ""); end -- cgit v1.2.3