From 3fdf0f66abb0a8e3443fd85dcd4370a7e384a3ad Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 12 Jun 2021 16:50:15 +0200 Subject: mod_admin_shell: Add basic command that shows more info about loaded modules To show info about loaded modules. Inspired by the desire to know whether a module was loaded from the core set or 3rd party. --- plugins/mod_admin_shell.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'plugins') diff --git a/plugins/mod_admin_shell.lua b/plugins/mod_admin_shell.lua index 2e24bdf2..95c7009b 100644 --- a/plugins/mod_admin_shell.lua +++ b/plugins/mod_admin_shell.lua @@ -216,6 +216,7 @@ function commands.help(session, data) elseif section == "http" then print [[http:list(hosts) - Show HTTP endpoints]] elseif section == "module" then + print [[module:info(module, host) - Show information about a loaded module]] print [[module:load(module, host) - Load the specified module on the specified host (or all hosts if none given)]] print [[module:reload(module, host) - The same, but unloads and loads the module (saving state if the module supports it)]] print [[module:unload(module, host) - The same, but just unloads the module from memory]] @@ -392,6 +393,34 @@ local function get_hosts_with_module(hosts, module) return hosts_set; end +function def_env.module:info(name, hosts) + if not name then + return nil, "module name expected"; + end + local print = self.session.print; + hosts = get_hosts_with_module(hosts, name); + if hosts:empty() then + return false, "mod_" .. name .. " does not appear to be loaded on the specified hosts"; + end + + for host in hosts do + local mod = modulemanager.get_module(host, name); + if mod.module.host == "*" then + print("in global context"); + elseif mod.module:get_host_type() == "local" then + print("on VirtualHost " .. mod.module.host); + elseif mod.module:get_host_type() == "component" then + local component_type = module:context(host):get_option_string("component_module", type); + if component_type == "component" then + component_type = "external"; + end + print("on " .. component_type .. " Component " .. mod.module.host); + end + print(" path: " .. (mod.module.path or "n/a")); + end + return true; +end + function def_env.module:load(name, hosts, config) hosts = get_hosts_with_module(hosts); -- cgit v1.2.3