aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2010-12-12 17:10:24 +0500
committerWaqas Hussain <waqas20@gmail.com>2010-12-12 17:10:24 +0500
commitfc9f921bc2fa3d8c93d7699ae99a4c12888a7373 (patch)
treee59ab9bd01c4ccd793c8df3fc2b6e7d69ce25d13
parenta985caeff2f624190575c34d927b966d7af3945b (diff)
downloadprosody-fc9f921bc2fa3d8c93d7699ae99a4c12888a7373.tar.gz
prosody-fc9f921bc2fa3d8c93d7699ae99a4c12888a7373.zip
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
-rwxr-xr-xprosodyctl27
1 files changed, 24 insertions, 3 deletions
diff --git a/prosodyctl b/prosodyctl
index 94816c56..bbd051a8 100755
--- a/prosodyctl
+++ b/prosodyctl
@@ -40,9 +40,30 @@ local prosody = prosody;
config = require "core.configmanager"
do
- -- TODO: Check for other formats when we add support for them
- -- Use lfs? Make a new conf/ dir?
- local ok, level, err = config.load((CFG_CONFIGDIR or ".").."/prosody.cfg.lua");
+ local filenames = {};
+
+ local filename;
+ if arg[1] == "--config" and arg[2] then
+ table.insert(filenames, arg[2]);
+ table.remove(arg, 1); table.remove(arg, 1);
+ if CFG_CONFIGDIR then
+ table.insert(filenames, CFG_CONFIGDIR.."/"..arg[2]);
+ end
+ else
+ for _, format in ipairs(config.parsers()) do
+ table.insert(filenames, (CFG_CONFIGDIR or ".").."/prosody.cfg."..format);
+ end
+ end
+ for _,_filename in ipairs(filenames) do
+ filename = _filename;
+ local file = io.open(filename);
+ if file then
+ file:close();
+ CFG_CONFIGDIR = filename:match("^(.*)[\\/][^\\/]*$");
+ break;
+ end
+ end
+ local ok, level, err = config.load(filename);
if not ok then
print("\n");
print("**************************");