diff options
author | Kim Alvefur <zash@zash.se> | 2021-06-12 16:50:15 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2021-06-12 16:50:15 +0200 |
commit | 3fdf0f66abb0a8e3443fd85dcd4370a7e384a3ad (patch) | |
tree | ce76b3ca207e565de526ae6b0e177fca7dfc6e25 /plugins | |
parent | 2562f23efcde00bb21f9dae9c389d05eaa797ab9 (diff) | |
download | prosody-3fdf0f66abb0a8e3443fd85dcd4370a7e384a3ad.tar.gz prosody-3fdf0f66abb0a8e3443fd85dcd4370a7e384a3ad.zip |
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.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_admin_shell.lua | 29 |
1 files changed, 29 insertions, 0 deletions
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); |