# HG changeset patch # User Kim Alvefur # Date 1680946135 -7200 # Node ID da51c36ed1e7ea66ae6ccdea5c2903662fae4671 # Parent 7e0bb5154f3b3a473b69ca56de45f1c1f4e6ac9d 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. diff -r 7e0bb5154f3b -r da51c36ed1e7 plugins/mod_admin_shell.lua --- a/plugins/mod_admin_shell.lua Sat Apr 08 10:16:18 2023 +0200 +++ b/plugins/mod_admin_shell.lua Sat Apr 08 11:28:55 2023 +0200 @@ -313,6 +313,7 @@ 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 @@ 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);