diff options
author | Kim Alvefur <zash@zash.se> | 2018-03-29 16:27:11 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2018-03-29 16:27:11 +0200 |
commit | 8a2aef3598753c98f4e060c17fa846deb49e63fe (patch) | |
tree | b28e816325d45886f36bc2574928ad7791b9e99d /util/startup.lua | |
parent | 14b0dd8bdf55d5d282221d42352364ec0862c834 (diff) | |
download | prosody-8a2aef3598753c98f4e060c17fa846deb49e63fe.tar.gz prosody-8a2aef3598753c98f4e060c17fa846deb49e63fe.zip |
util.startup: Factor out processing of plugin and data paths into a separate functions
Diffstat (limited to 'util/startup.lua')
-rw-r--r-- | util/startup.lua | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/util/startup.lua b/util/startup.lua index ba83eca5..a33f3f3b 100644 --- a/util/startup.lua +++ b/util/startup.lua @@ -192,16 +192,8 @@ function startup.init_global_state() full_sessions = prosody.full_sessions; hosts = prosody.hosts; - local data_path = config.get("*", "data_path") or CFG_DATADIR or "data"; - local custom_plugin_paths = config.get("*", "plugin_paths"); - if custom_plugin_paths then - local path_sep = package.config:sub(3,3); - -- path1;path2;path3;defaultpath... - -- luacheck: ignore 111 - CFG_PLUGINDIR = table.concat(custom_plugin_paths, path_sep)..path_sep..(CFG_PLUGINDIR or "plugins"); - end prosody.paths = { source = CFG_SOURCEDIR, config = CFG_CONFIGDIR or ".", - plugins = CFG_PLUGINDIR or "plugins", data = data_path }; + plugins = CFG_PLUGINDIR or "plugins", data = "data" }; prosody.arg = _G.arg; @@ -210,6 +202,21 @@ function startup.init_global_state() _G.prosody = prosody; end +function startup.setup_datadir() + prosody.paths.data = config.get("*", "data_path") or CFG_DATADIR or "data"; +end + +function startup.setup_plugindir() + local custom_plugin_paths = config.get("*", "plugin_paths"); + if custom_plugin_paths then + local path_sep = package.config:sub(3,3); + -- path1;path2;path3;defaultpath... + -- luacheck: ignore 111 + CFG_PLUGINDIR = table.concat(custom_plugin_paths, path_sep)..path_sep..(CFG_PLUGINDIR or "plugins"); + end + prosody.paths.plugins = CFG_PLUGINDIR; +end + function startup.chdir() if prosody.installed then -- Change working directory to data path. @@ -491,6 +498,8 @@ end function startup.prosodyctl() startup.read_config(); startup.init_global_state(); + startup.setup_plugindir(); + startup.setup_datadir(); startup.chdir(); startup.read_version(); startup.switch_user(); @@ -515,6 +524,8 @@ function startup.prosody() startup.check_dependencies(); startup.load_libraries(); startup.init_global_state(); + startup.setup_plugindir(); + startup.setup_datadir(); startup.init_logging(); startup.chdir(); startup.add_global_prosody_functions(); |