OC-PsychOS2/exec/init.lua

27 lines
554 B
Lua
Raw Normal View History

if os.taskInfo(1) then
return false, "init already started"
end
os.setenv("PWD","/boot")
io.input("/dev/null")
io.output("/dev/syslog")
local pids = {}
local function loadlist()
local f = io.open("/boot/cfg/init.txt","rb")
if not f then return false end
for line in f:read("*a"):gmatch("[^\r\n]+") do
dprint(line)
pids[line] = -1
2019-11-04 08:55:04 +11:00
end
f:close()
2019-11-04 08:55:04 +11:00
end
loadlist()
2019-11-04 08:55:04 +11:00
while true do
for k,v in pairs(pids) do
if not os.taskInfo(v) then
dprint("Starting service "..k)
pids[k] = os.spawnfile("/boot/service/"..k)
end
end
2019-11-04 08:55:04 +11:00
coroutine.yield()
end