From e6c50bbe6575b68fd443131a606f07758933dbeb Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sat, 29 Nov 2008 22:20:59 +0000 Subject: Add -fPIC to util-src/Makefile --- util-src/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util-src/Makefile b/util-src/Makefile index 90e80aea..8b886a1f 100644 --- a/util-src/Makefile +++ b/util-src/Makefile @@ -21,8 +21,8 @@ clean: rm -f ../util/*.so encodings.so: encodings.c - gcc -shared encodings.c -I$(LUA_INCDIR) -l$(LUA_LIB) -l$(IDN_LIB) -o encodings.so + gcc -shared -fPIC encodings.c -I$(LUA_INCDIR) -l$(LUA_LIB) -l$(IDN_LIB) -o encodings.so hashes.so: hashes.c - gcc -shared hashes.c -I$(LUA_INCDIR) -l$(LUA_LIB) -l$(OPENSSL_LIB) -o hashes.so + gcc -shared -fPIC hashes.c -I$(LUA_INCDIR) -l$(LUA_LIB) -l$(OPENSSL_LIB) -o hashes.so -- cgit v1.2.3 From b45c3b642407cd5606826a866880532d8dc0a36b Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sat, 29 Nov 2008 22:28:11 +0000 Subject: Don't write to prosody.cfg.lua from Makefile. Much apologies to poor albert :( --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 9fca034c..4f028abe 100644 --- a/Makefile +++ b/Makefile @@ -25,12 +25,12 @@ install: prosody.install prosody.cfg.lua util/encodings.so util/encodings.so install -m644 plugins/* $(MODULES) install -m644 certs/* $(CONFIG)/certs install -m644 plugins/* $(MODULES) - install -m644 prosody.cfg.lua $(CONFIG)/prosody.cfg.lua + install -m644 prosody.cfg.lua.install $(CONFIG)/prosody.cfg.lua $(MAKE) install -C util-src clean: rm -f prosody.install - rm -f prosody.cfg.lua + rm -f prosody.cfg.lua.install $(MAKE) clean -C util-src util/encodings.so: @@ -43,5 +43,5 @@ prosody.install: prosody sed "s|^CFG_SOURCEDIR=.*;$$|CFG_SOURCEDIR='$(INSTALLEDSOURCE)';|;s|^CFG_CONFIGDIR=.*;$$|CFG_CONFIGDIR='$(INSTALLEDCONFIG)';|;s|^CFG_PLUGINDIR=.*;$$|CFG_PLUGINDIR='$(INSTALLEDMODULES)/';|;" prosody > prosody.install prosody.cfg.lua: - sed 's|certs/|$(INSTALLEDCONFIG)/certs/|' prosody.cfg.lua.dist > prosody.cfg.lua + sed 's|certs/|$(INSTALLEDCONFIG)/certs/|' prosody.cfg.lua.dist > prosody.cfg.lua.install -- cgit v1.2.3 From 7d497c2cfcee8e24e599409ece41baf952490378 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sat, 29 Nov 2008 22:55:16 +0000 Subject: Fix missing prosody.cfg.lua.install --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4f028abe..016009e5 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,6 @@ util/hashes.so: prosody.install: prosody sed "s|^CFG_SOURCEDIR=.*;$$|CFG_SOURCEDIR='$(INSTALLEDSOURCE)';|;s|^CFG_CONFIGDIR=.*;$$|CFG_CONFIGDIR='$(INSTALLEDCONFIG)';|;s|^CFG_PLUGINDIR=.*;$$|CFG_PLUGINDIR='$(INSTALLEDMODULES)/';|;" prosody > prosody.install -prosody.cfg.lua: +prosody.cfg.lua.install: sed 's|certs/|$(INSTALLEDCONFIG)/certs/|' prosody.cfg.lua.dist > prosody.cfg.lua.install -- cgit v1.2.3 From bf2042e1fa6b0228223223f71b73ea19611ceff1 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 30 Nov 2008 00:33:58 +0000 Subject: Yet another fix for the makefile :) --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 016009e5..38de9e68 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ INSTALLEDMODULES = $(PREFIX)/lib/prosody/modules all: $(MAKE) all -C util-src -install: prosody.install prosody.cfg.lua util/encodings.so util/encodings.so +install: prosody.install prosody.cfg.lua.install util/encodings.so util/encodings.so install -d $(BIN) $(CONFIG) $(MODULES) $(SOURCE) install -d $(CONFIG)/certs install -d $(SOURCE)/core $(SOURCE)/net $(SOURCE)/util -- cgit v1.2.3 From a59958809cd9dd8d4cdefaadcbdd6f553e5031df Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sun, 30 Nov 2008 06:01:37 +0500 Subject: Auto-create data directories on start --- prosody | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/prosody b/prosody index 58ebc16a..10aea492 100755 --- a/prosody +++ b/prosody @@ -56,7 +56,30 @@ do end end -require "util.datamanager".set_data_path(config.get("*", "core", "data_path") or "data"); +local data_path = config.get("*", "core", "data_path") or "data"; +local path_separator = "/"; if os.getenv("WINDIR") then path_separator = "\\" end +local _mkdir = {} +function mkdir(path) + path = path:gsub("/", path_separator); + --print("mkdir",path); + local x = io.popen("mkdir "..path.." 2>&1"):read("*a"); +end +function encode(s) return s and (s:gsub("%W", function (c) return string.format("%%%x", c:byte()); end)); end +function mkdirs(host) + if not _mkdir[host] then + local host_dir = string.format("%s/%s", data_path, encode(host)); + mkdir(host_dir); + mkdir(host_dir.."/accounts"); + mkdir(host_dir.."/vcard"); + mkdir(host_dir.."/roster"); + mkdir(host_dir.."/private"); + mkdir(host_dir.."/offline"); + _mkdir[host] = true; + end +end +mkdir(data_path); + +require "util.datamanager".set_data_path(data_path); local server = require "net.server" @@ -71,6 +94,7 @@ local defined_hosts = config.getconfig(); for host, host_config in pairs(defined_hosts) do if host ~= "*" and (host_config.core.enabled == nil or host_config.core.enabled) then hosts[host] = {type = "local", connected = true, sessions = {}, host = host, s2sout = {} }; + mkdirs(data_path.."/"..host); end end -- cgit v1.2.3 From 1f61290ffd69e4b7e1d953f43fcbbf2f4586ada6 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sun, 30 Nov 2008 06:14:41 +0500 Subject: Path fix for auto-creating directories --- prosody | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prosody b/prosody index 10aea492..77f72e7f 100755 --- a/prosody +++ b/prosody @@ -94,7 +94,7 @@ local defined_hosts = config.getconfig(); for host, host_config in pairs(defined_hosts) do if host ~= "*" and (host_config.core.enabled == nil or host_config.core.enabled) then hosts[host] = {type = "local", connected = true, sessions = {}, host = host, s2sout = {} }; - mkdirs(data_path.."/"..host); + mkdirs(host); end end -- cgit v1.2.3 From 72a0f04a6717b5c577bead62773333ee5f384082 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 30 Nov 2008 01:16:55 +0000 Subject: Don't overwrite config on make install if it already exists --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 38de9e68..bc534525 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ install: prosody.install prosody.cfg.lua.install util/encodings.so util/encoding install -m644 plugins/* $(MODULES) install -m644 certs/* $(CONFIG)/certs install -m644 plugins/* $(MODULES) - install -m644 prosody.cfg.lua.install $(CONFIG)/prosody.cfg.lua + test -e $(CONFIG)/prosody.cfg.lua || install -m644 prosody.cfg.lua.install $(CONFIG)/prosody.cfg.lua $(MAKE) install -C util-src clean: -- cgit v1.2.3 From 90aca9cd5cecd28a32461814938b88e0acb1c02a Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 30 Nov 2008 04:22:43 +0000 Subject: Installation improvements (auto-creation of data directories) --- Makefile | 15 +++++++++++---- configure | 18 +++++++++++++++++- prosody | 18 +++++------------- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index bc534525..6676fc5b 100644 --- a/Makefile +++ b/Makefile @@ -6,16 +6,18 @@ CONFIG = $(DESTDIR)$(SYSCONFDIR) MODULES = $(DESTDIR)$(PREFIX)/lib/prosody/modules SOURCE = $(DESTDIR)$(PREFIX)/lib/prosody +DATADIR?=data + INSTALLEDSOURCE = $(PREFIX)/lib/prosody INSTALLEDCONFIG = $(SYSCONFDIR) INSTALLEDMODULES = $(PREFIX)/lib/prosody/modules +INSTALLEDDATA = $(DATADIR) - -all: +all: prosody.install prosody.cfg.lua.install $(MAKE) all -C util-src install: prosody.install prosody.cfg.lua.install util/encodings.so util/encodings.so - install -d $(BIN) $(CONFIG) $(MODULES) $(SOURCE) + install -d $(BIN) $(CONFIG) $(MODULES) $(SOURCE) $(DATADIR) install -d $(CONFIG)/certs install -d $(SOURCE)/core $(SOURCE)/net $(SOURCE)/util install ./prosody.install $(BIN)/prosody @@ -40,7 +42,12 @@ util/hashes.so: $(MAKE) install -C util-src prosody.install: prosody - sed "s|^CFG_SOURCEDIR=.*;$$|CFG_SOURCEDIR='$(INSTALLEDSOURCE)';|;s|^CFG_CONFIGDIR=.*;$$|CFG_CONFIGDIR='$(INSTALLEDCONFIG)';|;s|^CFG_PLUGINDIR=.*;$$|CFG_PLUGINDIR='$(INSTALLEDMODULES)/';|;" prosody > prosody.install + cp prosody prosody.install + sed -i "s|^CFG_SOURCEDIR=.*;$$|CFG_SOURCEDIR='$(INSTALLEDSOURCE)';|;" prosody.install + sed -i "s|^CFG_CONFIGDIR=.*;$$|CFG_CONFIGDIR='$(INSTALLEDCONFIG)';|;" prosody.install + sed -i "s|^CFG_DATADIR=.*;$$|CFG_DATADIR='$(INSTALLEDDATA)';|;" prosody.install + # The trailing slash is intentional in this one + sed -i "s|^CFG_PLUGINDIR=.*;$$|CFG_PLUGINDIR='$(INSTALLEDMODULES)/';|;" prosody.install prosody.cfg.lua.install: sed 's|certs/|$(INSTALLEDCONFIG)/certs/|' prosody.cfg.lua.dist > prosody.cfg.lua.install diff --git a/configure b/configure index 9d071bc1..dda98cd7 100755 --- a/configure +++ b/configure @@ -4,13 +4,14 @@ PREFIX=/usr/local SYSCONFDIR="$PREFIX/etc/prosody" +DATADIR="$PREFIX/var/lib/prosody" LUA_SUFFIX="" LUA_DIR="/usr" LUA_BINDIR="/usr/bin" LUA_INCDIR="/usr/include" LUA_LIBDIR="/usr/lib" IDN_LIB=idn -OPENSSL_LIB=ssl +OPENSSL_LIB=crypto # Help @@ -23,6 +24,8 @@ Configure Prosody prior to building. Default is $PREFIX --sysconfdir=DIR Location where the config file should be installed. Default is \$PREFIX/etc/prosody +--datadir=DIR Location where the server data should be stored. + Default is \$PREFIX/var/lib/prosody --lua-suffix=SUFFIX Versioning suffix to use in Lua filenames. Default is "$LUA_SUFFIX" (lua$LUA_SUFFIX...) --with-lua=PREFIX Use Lua from given prefix. @@ -60,6 +63,10 @@ do PREFIX="$value" PREFIX_SET=yes ;; + --data-dir=*) + DATADIR="$value" + DATADIR_SET=yes + ;; --require-config) REQUIRE_CONFIG=yes ;; @@ -100,6 +107,14 @@ then fi fi +if [ "$PREFIX_SET" = "yes" -a ! "$DATADIR_SET" = "yes" ] +then + if [ "$PREFIX" = "/usr" ] + then DATADIR=/var/lib/prosody + else DATADIR=$PREFIX/var/lib/prosody + fi +fi + find_program() { path="$PATH" item="`echo "$path" | sed 's/\([^:]*\):.*/\1/'`" @@ -221,6 +236,7 @@ cat < config.unix PREFIX=$PREFIX SYSCONFDIR=$SYSCONFDIR +DATADIR=$DATADIR LUA_SUFFIX=$LUA_SUFFIX LUA_DIR=$LUA_DIR LUA_INCDIR=$LUA_INCDIR diff --git a/prosody b/prosody index 77f72e7f..dd3cd068 100755 --- a/prosody +++ b/prosody @@ -5,28 +5,20 @@ CFG_SOURCEDIR=nil; CFG_CONFIGDIR=nil; CFG_PLUGINDIR=nil; +CFG_DATADIR=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.."/?.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 CFG_DATADIR then if os.getenv("HOME") then - CFG_PLUGINDIR = CFG_PLUGINDIR:gsub("^~", os.getenv("HOME")); + CFG_DATADIR = CFG_DATADIR:gsub("^~", os.getenv("HOME")); end -end +end -- Required to be able to find packages installed with luarocks pcall(require, "luarocks.require") @@ -56,7 +48,7 @@ do end end -local data_path = config.get("*", "core", "data_path") or "data"; +local data_path = config.get("*", "core", "data_path") or CFG_DATADIR or "data"; local path_separator = "/"; if os.getenv("WINDIR") then path_separator = "\\" end local _mkdir = {} function mkdir(path) -- cgit v1.2.3