aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-04-08 11:28:55 +0200
committerKim Alvefur <zash@zash.se>2023-04-08 11:28:55 +0200
commitdbb0c688cb08338bb276a1ed5fe9499e71a34d80 (patch)
tree03d61366944fd8d45098c594c917c9b6f0634d6b
parent9f691e9796634784f459bc0dbbc35dad83b104c3 (diff)
downloadprosody-dbb0c688cb08338bb276a1ed5fe9499e71a34d80.tar.gz
prosody-dbb0c688cb08338bb276a1ed5fe9499e71a34d80.zip
mod_admin_shell: Add config:set([host,] key, value) because why not
We had config:get() but not this. > <MattJ> Yeah, why did we never implement that? Handy if you want to quickly try out settings without reloading the whole config.
-rw-r--r--plugins/mod_admin_shell.lua8
1 files changed, 8 insertions, 0 deletions
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);