Merge 0.10->trunk
[prosody.git] / prosodyctl
index 2f9a7849829f3a0c5135474d679efcceca4dd4a9..910b96bf2cb8f82f7874a0a6ab58985bced007fa 100755 (executable)
@@ -220,6 +220,7 @@ local error_messages = setmetatable({
                ["no-such-host"] = "The given hostname does not exist in the config";
                ["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";
+               ["invalid-pidfile"] = "The 'pidfile' option in the configuration file is not a string, see http://prosody.im/doc/prosodyctl#pidfile for help";
                ["no-posix"] = "The mod_posix module is not enabled in the Prosody config file, see http://prosody.im/doc/prosodyctl for more info";
                ["no-such-method"] = "This module has no commands";
                ["not-running"] = "Prosody is not running";
@@ -268,13 +269,14 @@ local show_yesno = prosodyctl.show_yesno;
 local show_prompt = prosodyctl.show_prompt;
 local read_password = prosodyctl.read_password;
 
+local jid_split = require "util.jid".prepped_split;
+
 local prosodyctl_timeout = (config.get("*", "prosodyctl_timeout") or 5) * 2;
 -----------------------
 local commands = {};
 local command = arg[1];
 
 function commands.adduser(arg)
-       local jid_split = require "util.jid".split;
        if not arg[1] or arg[1] == "--help" then
                show_usage([[adduser JID]], [[Create the specified user account in Prosody]]);
                return 1;
@@ -314,7 +316,6 @@ function commands.adduser(arg)
 end
 
 function commands.passwd(arg)
-       local jid_split = require "util.jid".split;
        if not arg[1] or arg[1] == "--help" then
                show_usage([[passwd JID]], [[Set the password for the specified user account in Prosody]]);
                return 1;
@@ -354,7 +355,6 @@ function commands.passwd(arg)
 end
 
 function commands.deluser(arg)
-       local jid_split = require "util.jid".split;
        if not arg[1] or arg[1] == "--help" then
                show_usage([[deluser JID]], [[Permanently remove the specified user account from Prosody]]);
                return 1;
@@ -373,7 +373,6 @@ function commands.deluser(arg)
        
        if not hosts[host] then
                show_warning("The host '%s' is not listed in the configuration file (or is not enabled).", host)
-               show_warning("The user will not be able to log in until this is changed.");
                hosts[host] = make_host(host);
        end
 
@@ -831,6 +830,17 @@ function commands.check(arg)
                        print("    No global options defined. Perhaps you have put a host definition at the top")
                        print("    of the config file? They should be at the bottom, see http://prosody.im/doc/configure#overview");
                end
+               if it.count(enabled_hosts()) == 0 then
+                       ok = false;
+                       print("");
+                       if it.count(it.filter("*", pairs(config))) == 0 then
+                               print("    No hosts are defined, please add at least one VirtualHost section")
+                       elseif config["*"]["enabled"] == false then
+                               print("    No hosts are enabled. Remove enabled = false from the global section or put enabled = true under at least one VirtualHost section")
+                       else
+                               print("    All hosts are disabled. Remove enabled = false from at least one VirtualHost section")
+                       end
+               end
                -- Check for global options under hosts
                local global_options = set.new(it.to_array(it.keys(config["*"])));
                local deprecated_global_options = set.intersection(global_options, deprecated);