Software / code / prosody
Comparison
prosodyctl @ 3739:9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Sun, 12 Dec 2010 17:10:24 +0500 |
| parent | 3724:c12ebbd4ab61 |
| child | 3741:f7dd583d99b4 |
comparison
equal
deleted
inserted
replaced
| 3738:ae2ac97b23b1 | 3739:9ee223177319 |
|---|---|
| 38 local prosody = prosody; | 38 local prosody = prosody; |
| 39 | 39 |
| 40 config = require "core.configmanager" | 40 config = require "core.configmanager" |
| 41 | 41 |
| 42 do | 42 do |
| 43 -- TODO: Check for other formats when we add support for them | 43 local filenames = {}; |
| 44 -- Use lfs? Make a new conf/ dir? | 44 |
| 45 local ok, level, err = config.load((CFG_CONFIGDIR or ".").."/prosody.cfg.lua"); | 45 local filename; |
| 46 if arg[1] == "--config" and arg[2] then | |
| 47 table.insert(filenames, arg[2]); | |
| 48 table.remove(arg, 1); table.remove(arg, 1); | |
| 49 if CFG_CONFIGDIR then | |
| 50 table.insert(filenames, CFG_CONFIGDIR.."/"..arg[2]); | |
| 51 end | |
| 52 else | |
| 53 for _, format in ipairs(config.parsers()) do | |
| 54 table.insert(filenames, (CFG_CONFIGDIR or ".").."/prosody.cfg."..format); | |
| 55 end | |
| 56 end | |
| 57 for _,_filename in ipairs(filenames) do | |
| 58 filename = _filename; | |
| 59 local file = io.open(filename); | |
| 60 if file then | |
| 61 file:close(); | |
| 62 CFG_CONFIGDIR = filename:match("^(.*)[\\/][^\\/]*$"); | |
| 63 break; | |
| 64 end | |
| 65 end | |
| 66 local ok, level, err = config.load(filename); | |
| 46 if not ok then | 67 if not ok then |
| 47 print("\n"); | 68 print("\n"); |
| 48 print("**************************"); | 69 print("**************************"); |
| 49 if level == "parser" then | 70 if level == "parser" then |
| 50 print("A problem occured while reading the config file "..(CFG_CONFIGDIR or ".").."/prosody.cfg.lua"); | 71 print("A problem occured while reading the config file "..(CFG_CONFIGDIR or ".").."/prosody.cfg.lua"); |