1 #!/usr/bin/env lua |
1 #!/usr/bin/env lua |
2 |
2 |
3 -- Config here -- |
3 -- Config here -- |
4 |
4 |
5 |
5 CFG_SOURCEDIR=nil; |
|
6 CFG_CONFIGDIR=nil; |
|
7 CFG_PLUGINDIR=nil; |
6 |
8 |
7 -- -- -- -- -- -- |
9 -- -- -- -- -- -- |
8 |
10 |
9 if CFG_SOURCEDIR then |
11 if CFG_SOURCEDIR then |
|
12 if os.getenv("HOME") then |
|
13 CFG_SOURCEDIR = CFG_SOURCEDIR:gsub("^~", os.getenv("HOME")); |
|
14 end |
10 package.path = CFG_SOURCEDIR.."/?.lua;"..package.path |
15 package.path = CFG_SOURCEDIR.."/?.lua;"..package.path |
11 package.cpath = CFG_SOURCEDIR.."/?.lua;"..package.cpath |
16 package.cpath = CFG_SOURCEDIR.."/?.so;"..package.cpath |
12 end |
17 end |
|
18 |
|
19 if CFG_CONFIGDIR then |
|
20 if os.getenv("HOME") then |
|
21 CFG_CONFIGDIR = CFG_CONFIGDIR:gsub("^~", os.getenv("HOME")); |
|
22 end |
|
23 end |
|
24 |
|
25 if CFG_PLUGINDIR then |
|
26 if os.getenv("HOME") then |
|
27 CFG_PLUGINDIR = CFG_PLUGINDIR:gsub("^~", os.getenv("HOME")); |
|
28 end |
|
29 end |
13 |
30 |
14 -- Required to be able to find packages installed with luarocks |
31 -- Required to be able to find packages installed with luarocks |
15 pcall(require, "luarocks.require") |
32 pcall(require, "luarocks.require") |
16 |
33 |
17 |
34 |
19 log = require "util.logger".init("general"); |
36 log = require "util.logger".init("general"); |
20 |
37 |
21 do |
38 do |
22 -- TODO: Check for other formats when we add support for them |
39 -- TODO: Check for other formats when we add support for them |
23 -- Use lfs? Make a new conf/ dir? |
40 -- Use lfs? Make a new conf/ dir? |
24 local ok, err = config.load("lxmppd.cfg.lua"); |
41 local ok, err = config.load((CFG_CONFIGDIR or ".").."/prosody.cfg.lua"); |
25 if not ok then |
42 if not ok then |
26 log("error", "Couldn't load config file: %s", err); |
43 log("error", "Couldn't load config file: %s", err); |
27 log("info", "Falling back to old config file format...") |
44 log("info", "Falling back to old config file format...") |
28 ok, err = pcall(dofile, "lxmppd.cfg"); |
45 ok, err = pcall(dofile, "lxmppd.cfg"); |
29 if not ok then |
46 if not ok then |