prosody, prosodyctl: chdir() to data directory on startup
authorMatthew Wild <mwild1@gmail.com>
Wed, 19 Sep 2012 12:39:21 +0100
changeset 5134 43c5227fdd3b
parent 5133 1443d1c37c6c
child 5135 52eafe0e9772
child 5142 3221746f4769
prosody, prosodyctl: chdir() to data directory on startup
prosody
prosodyctl
--- a/prosody	Wed Sep 19 12:14:08 2012 +0100
+++ b/prosody	Wed Sep 19 12:39:21 2012 +0100
@@ -228,6 +228,11 @@
 		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");
--- a/prosodyctl	Wed Sep 19 12:14:08 2012 +0100
+++ b/prosodyctl	Wed Sep 19 12:39:21 2012 +0100
@@ -50,6 +50,7 @@
 	platform = "posix";
 	lock_globals = function () end;
 	unlock_globals = function () end;
+	installed = CFG_SOURCEDIR ~= nil;
 };
 _G.prosody = prosody;
 
@@ -119,6 +120,11 @@
 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();