util/startup.lua
changeset 8701 0499f3da0ec4
parent 8695 a55574754e5f
child 8702 580c13ed0ca1
equal deleted inserted replaced
8700:c60fdf148118 8701:0499f3da0ec4
   190 	-- luacheck: ignore 111/bare_sessions 111/full_sessions 111/hosts
   190 	-- luacheck: ignore 111/bare_sessions 111/full_sessions 111/hosts
   191 	bare_sessions = prosody.bare_sessions;
   191 	bare_sessions = prosody.bare_sessions;
   192 	full_sessions = prosody.full_sessions;
   192 	full_sessions = prosody.full_sessions;
   193 	hosts = prosody.hosts;
   193 	hosts = prosody.hosts;
   194 
   194 
   195 	local data_path = config.get("*", "data_path") or CFG_DATADIR or "data";
   195 	prosody.paths = { source = CFG_SOURCEDIR, config = CFG_CONFIGDIR or ".",
       
   196 	                  plugins = CFG_PLUGINDIR or "plugins", data = "data" };
       
   197 
       
   198 	prosody.arg = _G.arg;
       
   199 
       
   200 	startup.detect_platform();
       
   201 	startup.detect_installed();
       
   202 	_G.prosody = prosody;
       
   203 end
       
   204 
       
   205 function startup.setup_datadir()
       
   206 	prosody.paths.data = config.get("*", "data_path") or CFG_DATADIR or "data";
       
   207 end
       
   208 
       
   209 function startup.setup_plugindir()
   196 	local custom_plugin_paths = config.get("*", "plugin_paths");
   210 	local custom_plugin_paths = config.get("*", "plugin_paths");
   197 	if custom_plugin_paths then
   211 	if custom_plugin_paths then
   198 		local path_sep = package.config:sub(3,3);
   212 		local path_sep = package.config:sub(3,3);
   199 		-- path1;path2;path3;defaultpath...
   213 		-- path1;path2;path3;defaultpath...
   200 		-- luacheck: ignore 111
   214 		-- luacheck: ignore 111
   201 		CFG_PLUGINDIR = table.concat(custom_plugin_paths, path_sep)..path_sep..(CFG_PLUGINDIR or "plugins");
   215 		CFG_PLUGINDIR = table.concat(custom_plugin_paths, path_sep)..path_sep..(CFG_PLUGINDIR or "plugins");
   202 	end
   216 	end
   203 	prosody.paths = { source = CFG_SOURCEDIR, config = CFG_CONFIGDIR or ".",
   217 	prosody.paths.plugins = CFG_PLUGINDIR;
   204 	                  plugins = CFG_PLUGINDIR or "plugins", data = data_path };
       
   205 
       
   206 	prosody.arg = _G.arg;
       
   207 
       
   208 	startup.detect_platform();
       
   209 	startup.detect_installed();
       
   210 	_G.prosody = prosody;
       
   211 end
   218 end
   212 
   219 
   213 function startup.chdir()
   220 function startup.chdir()
   214 	if prosody.installed then
   221 	if prosody.installed then
   215 		-- Change working directory to data path.
   222 		-- Change working directory to data path.
   489 
   496 
   490 -- prosodyctl only
   497 -- prosodyctl only
   491 function startup.prosodyctl()
   498 function startup.prosodyctl()
   492 	startup.read_config();
   499 	startup.read_config();
   493 	startup.init_global_state();
   500 	startup.init_global_state();
       
   501 	startup.setup_plugindir();
       
   502 	startup.setup_datadir();
   494 	startup.chdir();
   503 	startup.chdir();
   495 	startup.read_version();
   504 	startup.read_version();
   496 	startup.switch_user();
   505 	startup.switch_user();
   497 	startup.check_dependencies();
   506 	startup.check_dependencies();
   498 	startup.force_console_logging();
   507 	startup.force_console_logging();
   513 	startup.sandbox_require();
   522 	startup.sandbox_require();
   514 	startup.set_function_metatable();
   523 	startup.set_function_metatable();
   515 	startup.check_dependencies();
   524 	startup.check_dependencies();
   516 	startup.load_libraries();
   525 	startup.load_libraries();
   517 	startup.init_global_state();
   526 	startup.init_global_state();
       
   527 	startup.setup_plugindir();
       
   528 	startup.setup_datadir();
   518 	startup.init_logging();
   529 	startup.init_logging();
   519 	startup.chdir();
   530 	startup.chdir();
   520 	startup.add_global_prosody_functions();
   531 	startup.add_global_prosody_functions();
   521 	startup.read_version();
   532 	startup.read_version();
   522 	startup.log_greeting();
   533 	startup.log_greeting();