aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/mod_storage_sql.lua11
-rwxr-xr-xprosody7
-rwxr-xr-xprosodyctl7
-rw-r--r--util/datamanager.lua3
4 files changed, 18 insertions, 10 deletions
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua
index 3afbab1c..63f75991 100644
--- a/plugins/mod_storage_sql.lua
+++ b/plugins/mod_storage_sql.lua
@@ -32,11 +32,18 @@ local connection;
local host,user,store = module.host;
local params = module:get_option("sql");
+local resolve_relative_path = require "core.configmanager".resolve_relative_path;
+
do -- process options to get a db connection
local DBI = require "DBI";
- params = params or { driver = "SQLite3", database = "prosody.sqlite" };
- assert(params.driver and params.database, "invalid params");
+ params = params or { driver = "SQLite3" };
+
+ if params.driver == "SQLite3" then
+ params.database = resolve_relative_path(prosody.paths.data or ".", params.database or "prosody.sqlite");
+ end
+
+ assert(params.driver and params.database, "Both the SQL driver and the database need to be specified");
prosody.unlock_globals();
local dbh, err = DBI.Connect(
diff --git a/prosody b/prosody
index 42c3acad..8dcb0096 100755
--- a/prosody
+++ b/prosody
@@ -183,9 +183,10 @@ function init_global_state()
prosody.full_sessions = full_sessions;
prosody.hosts = hosts;
+ local data_path = config.get("*", "core", "data_path") or CFG_DATADIR or "data";
prosody.paths = { source = CFG_SOURCEDIR, config = CFG_CONFIGDIR,
- plugins = CFG_PLUGINDIR, data = CFG_DATADIR };
-
+ plugins = CFG_PLUGINDIR, data = data_path };
+
prosody.arg = _G.arg;
prosody.platform = "unknown";
@@ -344,8 +345,6 @@ function load_secondary_libraries()
end
function init_data_store()
- local data_path = config.get("*", "core", "data_path") or CFG_DATADIR or "data";
- require "util.datamanager".set_data_path(data_path);
require "core.storagemanager";
end
diff --git a/prosodyctl b/prosodyctl
index 18f430c5..2c31c641 100755
--- a/prosodyctl
+++ b/prosodyctl
@@ -109,13 +109,14 @@ end
local original_logging_config = config.get("*", "core", "log");
config.set("*", "core", "log", { { levels = { min="info" }, to = "console" } });
+local data_path = config.get("*", "core", "data_path") or CFG_DATADIR or "data";
+prosody.paths = { source = CFG_SOURCEDIR, config = CFG_CONFIGDIR,
+ plugins = CFG_PLUGINDIR, data = data_path };
+
require "core.loggingmanager"
dependencies.log_warnings();
-local data_path = config.get("*", "core", "data_path") or CFG_DATADIR or "data";
-require "util.datamanager".set_data_path(data_path);
-
-- Switch away from root and into the prosody user --
local switched_user, current_uid;
diff --git a/util/datamanager.lua b/util/datamanager.lua
index fbdfb581..5aee289d 100644
--- a/util/datamanager.lua
+++ b/util/datamanager.lua
@@ -22,6 +22,7 @@ local t_insert = table.insert;
local append = require "util.serialization".append;
local path_separator = "/"; if os.getenv("WINDIR") then path_separator = "\\" end
local lfs = require "lfs";
+local prosody = prosody;
local raw_mkdir;
if prosody.platform == "posix" then
@@ -56,7 +57,7 @@ local function mkdir(path)
return path;
end
-local data_path = "data";
+local data_path = prosody.paths.data;
local callbacks = {};
------- API -------------