X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=prosodyctl;h=18f430c5b22e1ad8b34c1d086ea89a6d61419888;hb=0b0a013d85bf1a2d4b5a6a339b8cf946ba77aa5d;hp=cfc5ca77a979d74268a5483455984ec2da170462;hpb=9a3943500dedbdbcf7a58a057665704327d3d7d6;p=prosody.git diff --git a/prosodyctl b/prosodyctl index cfc5ca77..18f430c5 100755 --- a/prosodyctl +++ b/prosodyctl @@ -18,10 +18,22 @@ CFG_DATADIR=os.getenv("PROSODY_DATADIR"); -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +local function is_relative(path) + local path_sep = package.config:sub(1,1); + return ((path_sep == "/" and path:sub(1,1) ~= "/") + or (path_sep == "\\" and (path:sub(1,1) ~= "/" and path:sub(2,3) ~= ":\\"))) +end + -- Tell Lua where to find our libraries if CFG_SOURCEDIR then - package.path = CFG_SOURCEDIR.."/?.lua;"..package.path; - package.cpath = CFG_SOURCEDIR.."/?.so;"..package.cpath; + local function filter_relative_paths(path) + if is_relative(path) then return ""; end + end + local function sanitise_paths(paths) + return (paths:gsub("[^;]+;?", filter_relative_paths):gsub(";;+", ";")); + end + package.path = sanitise_paths(CFG_SOURCEDIR.."/?.lua;"..package.path); + package.cpath = sanitise_paths(CFG_SOURCEDIR.."/?.so;"..package.cpath); end -- Substitute ~ with path to home directory in data path @@ -32,14 +44,19 @@ if CFG_DATADIR then end -- Global 'prosody' object -prosody = { +local prosody = { hosts = {}; events = require "util.events".new(); platform = "posix"; lock_globals = function () end; unlock_globals = function () end; }; -local prosody = prosody; +_G.prosody = prosody; + +local dependencies = require "util.dependencies"; +if not dependencies.check_dependencies() then + os.exit(1); +end config = require "core.configmanager" @@ -94,9 +111,7 @@ config.set("*", "core", "log", { { levels = { min="info" }, to = "console" } }); require "core.loggingmanager" -if not require "util.dependencies".check_dependencies() then - os.exit(1); -end +dependencies.log_warnings(); local data_path = config.get("*", "core", "data_path") or CFG_DATADIR or "data"; require "util.datamanager".set_data_path(data_path);