prosody, prosodyctl: chdir() to data directory on startup
authorMatthew Wild <mwild1@gmail.com>
Wed, 19 Sep 2012 11:39:21 +0000 (12:39 +0100)
committerMatthew Wild <mwild1@gmail.com>
Wed, 19 Sep 2012 11:39:21 +0000 (12:39 +0100)
prosody
prosodyctl

diff --git a/prosody b/prosody
index b8de92f59c4f235d0dc8e64b8d3c45b345a9cada..c1606874a4a6f77da359e1dce9f6e88458161119 100755 (executable)
--- a/prosody
+++ b/prosody
@@ -228,6 +228,11 @@ function init_global_state()
                prosody.installed = true;
        end
        
+       if prosody.installed then
+               -- Change working directory to data path.
+               require "lfs".chdir(data_path);
+       end
+
        -- Function to reload the config file
        function prosody.reload_config()
                log("info", "Reloading configuration file");
index 25570fc44f3521599b8b56b636d9808fc48c26bb..d4aa6d5ef57e05aea1fc349c4aa551514b3ac650 100755 (executable)
@@ -50,6 +50,7 @@ local prosody = {
        platform = "posix";
        lock_globals = function () end;
        unlock_globals = function () end;
+       installed = CFG_SOURCEDIR ~= nil;
 };
 _G.prosody = prosody;
 
@@ -119,6 +120,11 @@ end
 prosody.paths = { source = CFG_SOURCEDIR, config = CFG_CONFIGDIR, 
                  plugins = CFG_PLUGINDIR or "plugins", data = data_path };
 
+if prosody.installed then
+       -- Change working directory to data path.
+       require "lfs".chdir(data_path);
+end
+
 require "core.loggingmanager"
 
 dependencies.log_warnings();