prosody

changeset 2168
1a99a3bf3ce6
parent 2159
b8635ebd7f57
child 2321
7e7484a4e821
child 2825
914d7afb8212
equal deleted inserted replaced
2165:529af807ba1a 2168:1a99a3bf3ce6
12 CFG_SOURCEDIR=os.getenv("PROSODY_SRCDIR"); 12 CFG_SOURCEDIR=os.getenv("PROSODY_SRCDIR");
13 CFG_CONFIGDIR=os.getenv("PROSODY_CFGDIR"); 13 CFG_CONFIGDIR=os.getenv("PROSODY_CFGDIR");
14 CFG_PLUGINDIR=os.getenv("PROSODY_PLUGINDIR"); 14 CFG_PLUGINDIR=os.getenv("PROSODY_PLUGINDIR");
15 CFG_DATADIR=os.getenv("PROSODY_DATADIR"); 15 CFG_DATADIR=os.getenv("PROSODY_DATADIR");
16 16
17 -- -- -- -- -- -- -- ---- -- -- -- -- -- -- -- -- 17 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
18 18
19 if CFG_SOURCEDIR then 19 if CFG_SOURCEDIR then
20 package.path = CFG_SOURCEDIR.."/?.lua;"..package.path; 20 package.path = CFG_SOURCEDIR.."/?.lua;"..package.path;
21 package.cpath = CFG_SOURCEDIR.."/?.so;"..package.cpath; 21 package.cpath = CFG_SOURCEDIR.."/?.so;"..package.cpath;
22 end 22 end
56 config = require "core.configmanager" 56 config = require "core.configmanager"
57 57
58 function read_config() 58 function read_config()
59 -- TODO: Check for other formats when we add support for them 59 -- TODO: Check for other formats when we add support for them
60 -- Use lfs? Make a new conf/ dir? 60 -- Use lfs? Make a new conf/ dir?
61 local ok, level, err = config.load((CFG_CONFIGDIR or ".").."/prosody.cfg.lua"); 61 local filenames = {};
62
63 local filename;
64 if arg[1] == "--config" and arg[2] then
65 table.insert(filenames, arg[2]);
66 if CFG_CONFIGDIR then
67 table.insert(filenames, CFG_CONFIGDIR.."/"..arg[2]);
68 end
69 else
70 table.insert(filenames, (CFG_CONFIGDIR or ".").."/prosody.cfg.lua");
71 end
72 for _,_filename in ipairs(filenames) do
73 filename = _filename;
74 local file = io.open(filename);
75 if file then
76 file:close();
77 CFG_CONFIGDIR = filename:match("^(.*)[\\/][^\\/]*$");
78 break;
79 end
80 end
81 local ok, level, err = config.load(filename);
62 if not ok then 82 if not ok then
63 print("\n"); 83 print("\n");
64 print("**************************"); 84 print("**************************");
65 if level == "parser" then 85 if level == "parser" then
66 print("A problem occured while reading the config file "..(CFG_CONFIGDIR or ".").."/prosody.cfg.lua"); 86 print("A problem occured while reading the config file "..(CFG_CONFIGDIR or ".").."/prosody.cfg.lua");
80 os.exit(1); 100 os.exit(1);
81 end 101 end
82 end 102 end
83 103
84 function load_libraries() 104 function load_libraries()
85 --- Initialize logging 105 -- Initialize logging
86 require "core.loggingmanager" 106 require "core.loggingmanager"
87 107
88 --- Check runtime dependencies 108 -- Check runtime dependencies
89 require "util.dependencies" 109 require "util.dependencies"
90 110
91 --- Load socket framework 111 -- Load socket framework
92 server = require "net.server" 112 server = require "net.server"
93 end 113 end
94 114
95 function init_global_state() 115 function init_global_state()
96 bare_sessions = {}; 116 bare_sessions = {};

mercurial