X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=prosodyctl;h=2c31c641384a340d0e95916c81d4851a51829418;hb=b9b20aa3f85ac7d9c5a8b0cce21b5b490969ceaf;hp=bbd051a860de4eaa838d034843d44cdccb1aaf8e;hpb=10ae87ff8539df0c78f2fa2161a24a43145a4cce;p=prosody.git diff --git a/prosodyctl b/prosodyctl index bbd051a8..2c31c641 100755 --- a/prosodyctl +++ b/prosodyctl @@ -1,7 +1,7 @@ #!/usr/bin/env lua -- Prosody IM --- Copyright (C) 2008-2009 Matthew Wild --- Copyright (C) 2008-2009 Waqas Hussain +-- Copyright (C) 2008-2010 Matthew Wild +-- Copyright (C) 2008-2010 Waqas Hussain -- -- This project is MIT/X11 licensed. Please see the -- COPYING file in the source package for more information. @@ -11,18 +11,32 @@ -- Will be modified by configure script if run -- -CFG_SOURCEDIR=nil; +CFG_SOURCEDIR=os.getenv("PROSODY_SRCDIR"); CFG_CONFIGDIR=os.getenv("PROSODY_CFGDIR"); -CFG_PLUGINDIR=nil; +CFG_PLUGINDIR=os.getenv("PROSODY_PLUGINDIR"); 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 if CFG_DATADIR then if os.getenv("HOME") then CFG_DATADIR = CFG_DATADIR:gsub("^~", os.getenv("HOME")); @@ -30,12 +44,19 @@ if CFG_DATADIR then end -- Global 'prosody' object -prosody = { - hosts = {}, - events = require "util.events".new(), - platform = "posix" +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" @@ -88,14 +109,13 @@ end local original_logging_config = config.get("*", "core", "log"); config.set("*", "core", "log", { { levels = { min="info" }, to = "console" } }); -require "core.loggingmanager" +local data_path = config.get("*", "core", "data_path") or CFG_DATADIR or "data"; +prosody.paths = { source = CFG_SOURCEDIR, config = CFG_CONFIGDIR, + plugins = CFG_PLUGINDIR, data = data_path }; -if not require "util.dependencies".check_dependencies() then - os.exit(1); -end +require "core.loggingmanager" -local data_path = config.get("*", "core", "data_path") or CFG_DATADIR or "data"; -require "util.datamanager".set_data_path(data_path); +dependencies.log_warnings(); -- Switch away from root and into the prosody user -- local switched_user, current_uid; @@ -327,7 +347,7 @@ function commands.adduser(arg) if ok then return 0; end - show_message(error_messages[msg]) + show_message(msg) return 1; end