From dbb0c688cb08338bb276a1ed5fe9499e71a34d80 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 8 Apr 2023 11:28:55 +0200 Subject: mod_admin_shell: Add config:set([host,] key, value) because why not We had config:get() but not this. > Yeah, why did we never implement that? Handy if you want to quickly try out settings without reloading the whole config. --- plugins/mod_admin_shell.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/mod_admin_shell.lua b/plugins/mod_admin_shell.lua index 12fe2031..96497545 100644 --- a/plugins/mod_admin_shell.lua +++ b/plugins/mod_admin_shell.lua @@ -313,6 +313,7 @@ function commands.help(session, data) elseif section == "config" then print [[config:reload() - Reload the server configuration. Modules may need to be reloaded for changes to take effect.]] print [[config:get([host,] option) - Show the value of a config option.]] + print [[config:set([host,] option, value) - Update the value of a config option without writing to the config file.]] elseif section == "stats" then -- luacheck: ignore 542 print [[stats:show(pattern) - Show internal statistics, optionally filtering by name with a pattern]] print [[stats:show():cfgraph() - Show a cumulative frequency graph]] @@ -712,6 +713,13 @@ function def_env.config:get(host, key) return true, serialize_config(config_get(host, key)); end +function def_env.config:set(host, key, value) + if host ~= "*" and not prosody.hosts[host] then + host, key, value = "*", host, key; + end + return require "prosody.core.configmanager".set(host, key, value); +end + function def_env.config:reload() local ok, err = prosody.reload_config(); return ok, (ok and "Config reloaded (you may need to reload modules to take effect)") or tostring(err); -- cgit v1.2.3