Software / code / prosody
Comparison
plugins/mod_admin_shell.lua @ 13062:da51c36ed1e7
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.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 08 Apr 2023 11:28:55 +0200 |
| parent | 13061:7e0bb5154f3b |
| child | 13071:b5a419ac0f84 |
comparison
equal
deleted
inserted
replaced
| 13061:7e0bb5154f3b | 13062:da51c36ed1e7 |
|---|---|
| 311 elseif section == "xmpp" then | 311 elseif section == "xmpp" then |
| 312 print [[xmpp:ping(localhost, remotehost) -- Sends a ping to a remote XMPP server and reports the response]] | 312 print [[xmpp:ping(localhost, remotehost) -- Sends a ping to a remote XMPP server and reports the response]] |
| 313 elseif section == "config" then | 313 elseif section == "config" then |
| 314 print [[config:reload() - Reload the server configuration. Modules may need to be reloaded for changes to take effect.]] | 314 print [[config:reload() - Reload the server configuration. Modules may need to be reloaded for changes to take effect.]] |
| 315 print [[config:get([host,] option) - Show the value of a config option.]] | 315 print [[config:get([host,] option) - Show the value of a config option.]] |
| 316 print [[config:set([host,] option, value) - Update the value of a config option without writing to the config file.]] | |
| 316 elseif section == "stats" then -- luacheck: ignore 542 | 317 elseif section == "stats" then -- luacheck: ignore 542 |
| 317 print [[stats:show(pattern) - Show internal statistics, optionally filtering by name with a pattern]] | 318 print [[stats:show(pattern) - Show internal statistics, optionally filtering by name with a pattern]] |
| 318 print [[stats:show():cfgraph() - Show a cumulative frequency graph]] | 319 print [[stats:show():cfgraph() - Show a cumulative frequency graph]] |
| 319 print [[stats:show():histogram() - Show a histogram of selected metric]] | 320 print [[stats:show():histogram() - Show a histogram of selected metric]] |
| 320 elseif section == "debug" then | 321 elseif section == "debug" then |
| 710 end | 711 end |
| 711 local config_get = require "prosody.core.configmanager".get | 712 local config_get = require "prosody.core.configmanager".get |
| 712 return true, serialize_config(config_get(host, key)); | 713 return true, serialize_config(config_get(host, key)); |
| 713 end | 714 end |
| 714 | 715 |
| 716 function def_env.config:set(host, key, value) | |
| 717 if host ~= "*" and not prosody.hosts[host] then | |
| 718 host, key, value = "*", host, key; | |
| 719 end | |
| 720 return require "prosody.core.configmanager".set(host, key, value); | |
| 721 end | |
| 722 | |
| 715 function def_env.config:reload() | 723 function def_env.config:reload() |
| 716 local ok, err = prosody.reload_config(); | 724 local ok, err = prosody.reload_config(); |
| 717 return ok, (ok and "Config reloaded (you may need to reload modules to take effect)") or tostring(err); | 725 return ok, (ok and "Config reloaded (you may need to reload modules to take effect)") or tostring(err); |
| 718 end | 726 end |
| 719 | 727 |