util/startup.lua
changeset 10177 0513dd2830b7
parent 10175 628e238feb04
child 10178 55dc8eb1e7d3
equal deleted inserted replaced
10176:5da519ef2d51 10177:0513dd2830b7
   224 function startup.setup_datadir()
   224 function startup.setup_datadir()
   225 	prosody.paths.data = config.get("*", "data_path") or CFG_DATADIR or "data";
   225 	prosody.paths.data = config.get("*", "data_path") or CFG_DATADIR or "data";
   226 end
   226 end
   227 
   227 
   228 function startup.setup_plugindir()
   228 function startup.setup_plugindir()
       
   229 	--require "lfs".currentdir()
       
   230 	--local current_directory = lfs.currentdir()
   229 	local custom_plugin_paths = config.get("*", "plugin_paths");
   231 	local custom_plugin_paths = config.get("*", "plugin_paths");
   230 	local installer_plugin_paths = config.get("*", "installer_plugin_paths") or {"custom_plugins"};
   232 	local installer_plugin_path = config.get("*", "installer_plugin_path") or "custom_plugins";
       
   233 	local path_sep = package.config:sub(3,3);
   231 	if custom_plugin_paths then
   234 	if custom_plugin_paths then
   232 		local path_sep = package.config:sub(3,3);
       
   233 		-- path1;path2;path3;defaultpath...
   235 		-- path1;path2;path3;defaultpath...
   234 		-- luacheck: ignore 111
   236 		-- luacheck: ignore 111
   235 		CFG_PLUGINDIR = table.concat(custom_plugin_paths, path_sep)..path_sep..(CFG_PLUGINDIR or "plugins");
   237 		CFG_PLUGINDIR = table.concat(custom_plugin_paths, path_sep)..path_sep..(CFG_PLUGINDIR or "plugins");
   236 		prosody.paths.plugins = CFG_PLUGINDIR;
   238 		prosody.paths.plugins = CFG_PLUGINDIR;
   237 	end
   239 	end
   238 	for path, _ in ipairs(installer_plugin_paths) do
   240 	-- Checking if the folder exists. If it doesn't, we create it
   239 		if os.execute('[ -d "'..installer_plugin_paths[path]..'" ]') ~= 0 then
   241 	--[[if os.execute('[ -d "'..installer_plugin_path..'" ]') ~= 0 then
   240 			os.execute("mkdir "..installer_plugin_paths[path])
   242 		os.execute("mkdir "..installer_plugin_path)
   241 		end
   243 	end]]
   242 	end
   244 	--[[if not string.find(package.path, current_directory..installer_plugin_path[path]) then
   243 	local path_sep = package.config:sub(3,3);
   245 		--os.execute("ls -la "..current_directory..path_sep..installer_plugin_paths[path])
   244 	-- luacheck: ignore 111
   246 		package.path = package.path..path_sep..current_directory..installer_plugin_path.."/?.lua"..path_sep..path_sep
   245 	CFG_PLUGINDIR = table.concat(installer_plugin_paths, path_sep)..path_sep..(CFG_PLUGINDIR or "plugins");
   247 		package.path = package.path..current_directory..installer_plugin_path.."/?/init.lua"..path_sep..path_sep
       
   248 		package.cpath = package.cpath..path_sep..current_directory..installer_plugin_path.."/?.lua"
       
   249 		package.cpath = package.cpath..path_sep..current_directory..installer_plugin_path.."/?/init.lua"
       
   250 	end]]
       
   251 	CFG_PLUGINDIR = installer_plugin_path..path_sep..(CFG_PLUGINDIR or "plugins");
   246 	prosody.paths.plugins = CFG_PLUGINDIR;
   252 	prosody.paths.plugins = CFG_PLUGINDIR;
   247 end
   253 end
   248 
   254 
   249 function startup.chdir()
   255 function startup.chdir()
   250 	if prosody.installed then
   256 	if prosody.installed then