aboutsummaryrefslogtreecommitdiffstats
path: root/prosodyctl
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-06-23 15:58:56 +0100
committerMatthew Wild <mwild1@gmail.com>2009-06-23 15:58:56 +0100
commitf00a5d70b30b132b763b2e20c68accb8ce52789d (patch)
tree0741204836fedee0caea15f4607bd996d7e5fdab /prosodyctl
parent3f141a44c2b4564e5d88748f76f53f5fec6c1a33 (diff)
parent54bbd9c98aa6e40463982ec2a92fa9a444704b43 (diff)
downloadprosody-f00a5d70b30b132b763b2e20c68accb8ce52789d.tar.gz
prosody-f00a5d70b30b132b763b2e20c68accb8ce52789d.zip
Automated merge with http://waqas.ath.cx:8000/
Diffstat (limited to 'prosodyctl')
-rwxr-xr-xprosodyctl37
1 files changed, 37 insertions, 0 deletions
diff --git a/prosodyctl b/prosodyctl
index 27fda56d..642b12b8 100755
--- a/prosodyctl
+++ b/prosodyctl
@@ -94,12 +94,14 @@ local error_messages = setmetatable({
["no-such-user"] = "The given user does not exist on the server";
["unable-to-save-data"] = "Unable to store, perhaps you don't have permission?";
["no-pidfile"] = "There is no pidfile option in the configuration file, see http://prosody.im/doc/prosodyctl#pidfile for help";
+ ["no-such-method"] = "This module has no commands";
}, { __index = function (t,k) return "Error: "..(tostring(k):gsub("%-", " "):gsub("^.", string.upper)); end });
hosts = {};
require "core.hostmanager"
require "core.eventmanager".fire_event("server-starting");
+require "core.modulemanager"
require "util.prosodyctl"
-----------------------
@@ -404,6 +406,41 @@ end
---------------------
+if command:match("^mod_") then -- Is a command in a module
+ local module_name = command:match("^mod_(.+)");
+ local ret, err = modulemanager.load("*", module_name);
+ if not ret then
+ show_message("Failed to load module '"..module_name.."': "..err);
+ os.exit(1);
+ end
+
+ table.remove(arg, 1);
+
+ local module = modulemanager.get_module("*", module_name);
+ if not module then
+ show_message("Failed to load module '"..module_name.."': Unknown error");
+ os.exit(1);
+ end
+
+ if not modulemanager.module_has_method(module, "command") then
+ show_message("Fail: mod_"..module_name.." does not support any commands");
+ os.exit(1);
+ end
+
+ local ok, ret = modulemanager.call_module_method(module, "command", arg);
+ if ok then
+ if type(ret) == "number" then
+ os.exit(ret);
+ elseif type(ret) == "string" then
+ show_message(ret);
+ end
+ os.exit(0); -- :)
+ else
+ show_message("Failed to execute command: "..error_messages[ret]);
+ os.exit(1); -- :(
+ end
+end
+
if not commands[command] then -- Show help for all commands
function show_usage(usage, desc)
print(" "..usage);