aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-10-17 15:26:32 +0100
committerMatthew Wild <mwild1@gmail.com>2009-10-17 15:26:32 +0100
commit94f04512127f34d226649124eabf5dbfe4c28d7f (patch)
tree839b880971e9b3bfb659a8bdde535b4aabe5fa62 /plugins
parent5a0637e9e0e3385d7348645dd5a13b5e0cb383c5 (diff)
downloadprosody-94f04512127f34d226649124eabf5dbfe4c28d7f.tar.gz
prosody-94f04512127f34d226649124eabf5dbfe4c28d7f.zip
mod_console: Add commands host:activate(host, config) and host:deactivate(host, reason) to add/remove hosts at runtime
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_console.lua28
1 files changed, 28 insertions, 0 deletions
diff --git a/plugins/mod_console.lua b/plugins/mod_console.lua
index 5472eb91..552819c1 100644
--- a/plugins/mod_console.lua
+++ b/plugins/mod_console.lua
@@ -572,6 +572,34 @@ function def_env.s2s:close(from, to)
return true, "Closed "..count.." s2s session"..((count == 1 and "") or "s");
end
+def_env.host = {}; def_env.hosts = def_env.host;
+function def_env.host:activate(hostname, config)
+ local hostmanager_activate = require "core.hostmanager".activate;
+ if hosts[hostname] then
+ return false, "The host "..tostring(hostname).." is already activated";
+ end
+
+ local defined_hosts = config or configmanager.getconfig();
+ if not config and not defined_hosts[hostname] then
+ return false, "Couldn't find "..tostring(hostname).." defined in the config, perhaps you need to config:reload()?";
+ end
+ hostmanager_activate(hostname, config or defined_hosts[hostname]);
+ return true, "Host "..tostring(hostname).." activated";
+end
+
+function def_env.host:deactivate(hostname, reason)
+ local hostmanager_deactivate = require "core.hostmanager".deactivate;
+ local host = hosts[hostname];
+ if not host then
+ return false, "The host "..tostring(hostname).." is not activated";
+ end
+ if reason then
+ reason = { condition = "host-gone", text = reason };
+ end
+ hostmanager_deactivate(hostname, reason);
+ return true, "Host "..tostring(hostname).." deactivated";
+end
+
-------------
function printbanner(session)