summaryrefslogtreecommitdiffstatshomepage
path: root/plugins/boot.lua
blob: 9e5ac3a5f2a1616101448fd441c2217021bf118d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
-- license:BSD-3-Clause
-- copyright-holders:Miodrag Milanovic
require('lfs')
local cwd = lfs.currentdir()
package.path = cwd .. "/plugins/?.lua;" .. cwd .. "/plugins/?/init.lua"

local json = require('json')
function readAll(file)
    local f = io.open(file, "rb")
    local content = f:read("*all")
    f:close()
    return content
end

for file in lfs.dir("plugins") do
	if (file~="." and file~=".." and lfs.attributes("plugins/" .. file,"mode")=="directory") then
		local filename = "plugins/" .. file .. "/plugin.json"
		local meta = json.parse(readAll(filename))
		if (meta["plugin"]["type"]=="plugin") and (meta["plugin"]["start"]=="true") then
			server = require(meta["plugin"]["name"])
			if server.set_folder~=nil then server.set_folder("plugins/" .. file) end
			server.startplugin();
		end
	end
end