mod_saslauth: Add support for CyrusSASL.
[prosody.git] / util / prosodyctl.lua
index 4c6b6ea40e4476c73cf21c4af8c31c9eff1e8856..e44c78d7d14f69c2b6feaf1c0aa3f717f1655cff 100644 (file)
@@ -1,3 +1,11 @@
+-- Prosody IM
+-- Copyright (C) 2008-2009 Matthew Wild
+-- Copyright (C) 2008-2009 Waqas Hussain
+-- 
+-- This project is MIT/X11 licensed. Please see the
+-- COPYING file in the source package for more information.
+--
+
 
 local config = require "core.configmanager";
 local encodings = require "util.encodings";
@@ -9,6 +17,9 @@ local nodeprep, nameprep = stringprep.nodeprep, stringprep.nameprep;
 
 local io, os = io, os;
 local tostring, tonumber = tostring, tonumber;
+
+local CFG_SOURCEDIR = _G.CFG_SOURCEDIR;
+
 module "prosodyctl"
 
 function adduser(params)
@@ -19,7 +30,10 @@ function adduser(params)
                return false, "invalid-hostname";
        end
        
-       usermanager.create_user(user, password, host);
+       local ok = usermanager.create_user(user, password, host);
+       if not ok then
+               return false, "unable-to-save-data";
+       end
        return true;
 end
 
@@ -52,7 +66,7 @@ function getpid()
        
        local file, err = io.open(pidfile);
        if not file then
-               return false, "pidfile-read-failed", ret;
+               return false, "pidfile-read-failed", err;
        end
        
        local pid = tonumber(file:read("*a"));
@@ -88,10 +102,8 @@ function start()
        end
        if not CFG_SOURCEDIR then
                os.execute("./prosody");
-       elseif CFG_SOURCEDIR:match("^/usr/local") then
-               os.execute("/usr/local/bin/prosody");
        else
-               os.execute("prosody");
+               os.execute(CFG_SOURCEDIR.."/../../bin/prosody");
        end
        return true;
 end