aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2008-11-29 03:27:50 +0000
committerMatthew Wild <mwild1@gmail.com>2008-11-29 03:27:50 +0000
commit7271c148cef981f9263a8794ebe27634423b07bd (patch)
tree837729c161f9e2d3d65a08790d25bebb37e622e1
parent5b8969b8d9a926294b0f09b3f835ae994d58d012 (diff)
downloadprosody-7271c148cef981f9263a8794ebe27634423b07bd.tar.gz
prosody-7271c148cef981f9263a8794ebe27634423b07bd.zip
Update Makefile to now pass config paths to prosody. Update prosody, modulemanager and connectionlisteners to obey these paths.
-rw-r--r--Makefile10
-rwxr-xr-xconfigure2
-rw-r--r--core/modulemanager.lua5
-rw-r--r--net/connlisteners.lua5
-rwxr-xr-xprosody23
5 files changed, 34 insertions, 11 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/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...")