aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2008-11-30 01:02:12 +0000
committerMatthew Wild <mwild1@gmail.com>2008-11-30 01:02:12 +0000
commit5595358cb096a37c8f235f751e7dfbd8d5b4c6df (patch)
tree9d62caf284f782eee13a60ad6bc5ba066c1c51aa
parent95fb20f64d563533c7981893896ce4023526ca68 (diff)
parenta59958809cd9dd8d4cdefaadcbdd6f553e5031df (diff)
downloadprosody-5595358cb096a37c8f235f751e7dfbd8d5b4c6df.tar.gz
prosody-5595358cb096a37c8f235f751e7dfbd8d5b4c6df.zip
Merge from waqas
-rwxr-xr-xprosody26
1 files changed, 25 insertions, 1 deletions
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