Changeset

10163:661feb336e18

util.startup: Now it also loads default or configured paths to custom plugin directories and creates them
author João Duarte <jvsDuarte08@gmail.com>
date Wed, 24 Jul 2019 10:37:01 -0700
parents 10162:7a4c15f75deb
children 10164:d145eb696475
files util/startup.lua
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/util/startup.lua	Wed Jul 24 05:07:57 2019 -0700
+++ b/util/startup.lua	Wed Jul 24 10:37:01 2019 -0700
@@ -227,6 +227,7 @@
 
 function startup.setup_plugindir()
 	local custom_plugin_paths = config.get("*", "plugin_paths");
+	local installer_plugin_paths = config.get("*", "installer_plugin_paths") or {"custom_plugins"};
 	if custom_plugin_paths then
 		local path_sep = package.config:sub(3,3);
 		-- path1;path2;path3;defaultpath...
@@ -234,6 +235,17 @@
 		CFG_PLUGINDIR = table.concat(custom_plugin_paths, path_sep)..path_sep..(CFG_PLUGINDIR or "plugins");
 		prosody.paths.plugins = CFG_PLUGINDIR;
 	end
+	if installer_plugin_paths then
+		for path, _ in ipairs(installer_plugin_paths) do
+			if os.execute('[ -d "'..installer_plugin_paths[path]..'" ]') ~= 0 then
+				os.execute("mkdir "..installer_plugin_paths[path])
+			end
+		end
+		local path_sep = package.config:sub(3,3);
+		-- luacheck: ignore 111
+		CFG_PLUGINDIR = table.concat(installer_plugin_paths, path_sep)..path_sep..(CFG_PLUGINDIR or "plugins");
+		prosody.paths.plugins = CFG_PLUGINDIR;
+	end
 end
 
 function startup.chdir()