prosody

changeset 523
c0f15538f358
parent 502
21dc299387a6
child 524
3f9f67f1a106
equal deleted inserted replaced
522:fc3df507afa2 523:c0f15538f358
1 #!/usr/bin/env lua 1 #!/usr/bin/env lua
2 2
3 -- Config here -- 3 -- Config here --
4 4
5 CFG_SOURCEDIR=nil; 5 CFG_SOURCEDIR=nil;
6 CFG_CONFIGDIR=nil; 6 CFG_CONFIGDIR=os.getenv("PROSODY_CFGDIR");
7 CFG_PLUGINDIR=nil; 7 CFG_PLUGINDIR=nil;
8 CFG_DATADIR=nil; 8 CFG_DATADIR=os.getenv("PROSODY_DATADIR");
9 9
10 -- -- -- -- -- -- 10 -- -- -- -- -- --
11 11
12 if CFG_SOURCEDIR then 12 if CFG_SOURCEDIR then
13 package.path = CFG_SOURCEDIR.."/?.lua;"..package.path 13 package.path = CFG_SOURCEDIR.."/?.lua;"..package.path
52 local path_separator = "/"; if os.getenv("WINDIR") then path_separator = "\\" end 52 local path_separator = "/"; if os.getenv("WINDIR") then path_separator = "\\" end
53 local _mkdir = {} 53 local _mkdir = {}
54 function mkdir(path) 54 function mkdir(path)
55 path = path:gsub("/", path_separator); 55 path = path:gsub("/", path_separator);
56 --print("mkdir",path); 56 --print("mkdir",path);
57 local x = io.popen("mkdir "..path.." 2>&1"):read("*a"); 57 local x = io.popen("mkdir \""..path.."\" 2>&1"):read("*a");
58 end 58 end
59 function encode(s) return s and (s:gsub("%W", function (c) return string.format("%%%x", c:byte()); end)); end 59 function encode(s) return s and (s:gsub("%W", function (c) return string.format("%%%x", c:byte()); end)); end
60 function mkdirs(host) 60 function mkdirs(host)
61 if not _mkdir[host] then 61 if not _mkdir[host] then
62 local host_dir = string.format("%s/%s", data_path, encode(host)); 62 local host_dir = string.format("%s/%s", data_path, encode(host));

mercurial