aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile10
-rwxr-xr-xconfigure2
-rw-r--r--core/configmanager.lua10
-rw-r--r--core/modulemanager.lua5
-rw-r--r--net/connlisteners.lua5
-rwxr-xr-xprosody23
6 files changed, 41 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index f1c1a286..0a96d2e5 100644
--- a/Makefile
+++ b/Makefile
@@ -9,11 +9,10 @@ SOURCE = $(DESTDIR)$(PREFIX)/lib/prosody
all:
$(MAKE) all -C util-src
-install: prosody util/encodings.so util/encodings.so
-
+install: prosody.install util/encodings.so util/encodings.so
install -d $(BIN) $(CONFIG) $(MODULES) $(SOURCE)
install -d $(SOURCE)/core $(SOURCE)/net $(SOURCE)/util
- install ./prosody $(BIN)
+ install ./prosody.install $(BIN)/prosody
install -m644 core/* $(SOURCE)/core
install -m644 net/* $(SOURCE)/net
install -m644 util/* $(SOURCE)/util
@@ -22,6 +21,7 @@ install: prosody util/encodings.so util/encodings.so
$(MAKE) install -C util-src
clean:
+ rm -f prosody.install
$(MAKE) clean -C util-src
util/encodings.so:
@@ -29,3 +29,7 @@ util/encodings.so:
util/hashes.so:
$(MAKE) install -C util-src
+
+prosody.install: prosody
+ sed "s|^CFG_SOURCEDIR=.*;$$|CFG_SOURCEDIR='$(SOURCE)';|;s|^CFG_CONFIGDIR=.*;$$|CFG_CONFIGDIR='$(CONFIG)';|;s|^CFG_PLUGINDIR=.*;$$|CFG_PLUGINDIR='$(MODULES)/';|;" prosody > prosody.install
+
diff --git a/configure b/configure
index 758e70df..9d071bc1 100755
--- a/configure
+++ b/configure
@@ -125,7 +125,7 @@ find_program() {
if [ "$LUA_SUFFIX_SET" != "yes" ]
then
- for suffix in "" "5.1" "51" ""
+ for suffix in "5.1" "51" ""
do
LUA_SUFFIX="$suffix"
if [ "$LUA_DIR_SET" = "yes" ]
diff --git a/core/configmanager.lua b/core/configmanager.lua
index 5f5648b9..a4a24fad 100644
--- a/core/configmanager.lua
+++ b/core/configmanager.lua
@@ -2,6 +2,7 @@
local _G = _G;
local setmetatable, loadfile, pcall, rawget, rawset, io =
setmetatable, loadfile, pcall, rawget, rawset, io;
+
module "configmanager"
local parsers = {};
@@ -52,18 +53,21 @@ end
function load(filename, format)
format = format or filename:match("%w+$");
+
if parsers[format] and parsers[format].load then
- local f = io.open(filename);
+ local f, err = io.open(filename);
if f then
local ok, err = parsers[format].load(f:read("*a"));
f:close();
return ok, err;
end
+ return f, err;
end
+
if not format then
return nil, "no parser specified";
else
- return false, "no parser";
+ return nil, "no parser for "..(format);
end
end
@@ -118,4 +122,4 @@ do
end
-return _M; \ No newline at end of file
+return _M;
diff --git a/core/modulemanager.lua b/core/modulemanager.lua
index ce34f3e6..31059512 100644
--- a/core/modulemanager.lua
+++ b/core/modulemanager.lua
@@ -1,4 +1,5 @@
+local plugin_dir = CFG_PLUGINDIR or "./plugins/";
local logger = require "util.logger";
local log = logger.init("modulemanager")
@@ -11,8 +12,8 @@ local type = type;
local tostring, print = tostring, print;
+-- We need this to let modules access the real global namespace
local _G = _G;
-local debug = debug;
module "modulemanager"
@@ -30,7 +31,7 @@ function load(host, module_name, config)
if not (host and module_name) then
return nil, "insufficient-parameters";
end
- local mod, err = loadfile("plugins/mod_"..module_name..".lua");
+ local mod, err = loadfile(plugin_dir.."mod_"..module_name..".lua");
if not mod then
log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil");
return nil, err;
diff --git a/net/connlisteners.lua b/net/connlisteners.lua
index 2b95331c..cfb6aa39 100644
--- a/net/connlisteners.lua
+++ b/net/connlisteners.lua
@@ -1,4 +1,5 @@
+local listeners_dir = (CFG_SOURCEDIR or "").."/net/";
local server_add = require "net.server".add;
local log = require "util.logger".init("connlisteners");
@@ -26,7 +27,7 @@ end
function get(name)
local h = listeners[name];
if not h then
- pcall(dofile, "net/"..name:gsub("[^%w%-]", "_").."_listener.lua");
+ pcall(dofile, listeners_dir..name:gsub("[^%w%-]", "_").."_listener.lua");
h = listeners[name];
end
return h;
@@ -42,4 +43,4 @@ function start(name, udata)
(udata and udata.interface) or "*", (udata and udata.mode) or h.default_mode or 1, (udata and udata.ssl) or nil );
end
-return _M; \ No newline at end of file
+return _M;
diff --git a/prosody b/prosody
index 6f13decd..58ebc16a 100755
--- a/prosody
+++ b/prosody
@@ -2,15 +2,32 @@
-- Config here --
-
+CFG_SOURCEDIR=nil;
+CFG_CONFIGDIR=nil;
+CFG_PLUGINDIR=nil;
-- -- -- -- -- --
if CFG_SOURCEDIR then
+ if os.getenv("HOME") then
+ CFG_SOURCEDIR = CFG_SOURCEDIR:gsub("^~", os.getenv("HOME"));
+ end
package.path = CFG_SOURCEDIR.."/?.lua;"..package.path
- package.cpath = CFG_SOURCEDIR.."/?.lua;"..package.cpath
+ package.cpath = CFG_SOURCEDIR.."/?.so;"..package.cpath
end
+if CFG_CONFIGDIR then
+ if os.getenv("HOME") then
+ CFG_CONFIGDIR = CFG_CONFIGDIR:gsub("^~", os.getenv("HOME"));
+ end
+end
+
+if CFG_PLUGINDIR then
+ if os.getenv("HOME") then
+ CFG_PLUGINDIR = CFG_PLUGINDIR:gsub("^~", os.getenv("HOME"));
+ end
+end
+
-- Required to be able to find packages installed with luarocks
pcall(require, "luarocks.require")
@@ -21,7 +38,7 @@ log = require "util.logger".init("general");
do
-- TODO: Check for other formats when we add support for them
-- Use lfs? Make a new conf/ dir?
- local ok, err = config.load("lxmppd.cfg.lua");
+ local ok, err = config.load((CFG_CONFIGDIR or ".").."/prosody.cfg.lua");
if not ok then
log("error", "Couldn't load config file: %s", err);
log("info", "Falling back to old config file format...")