2019-11-09 14:59:53 +11:00
|
|
|
if os.taskInfo(1) and os.pid() ~= 1 then
|
2019-11-09 14:23:18 +11:00
|
|
|
return false, "init already started"
|
|
|
|
end
|
2019-11-06 14:28:40 +11:00
|
|
|
os.setenv("PWD","/boot")
|
2019-11-09 14:23:18 +11:00
|
|
|
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
|
2019-11-09 14:23:18 +11:00
|
|
|
f:close()
|
2019-11-04 08:55:04 +11:00
|
|
|
end
|
2019-11-09 14:23:18 +11:00
|
|
|
loadlist()
|
2019-11-04 08:55:04 +11:00
|
|
|
while true do
|
2019-11-09 14:23:18 +11:00
|
|
|
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
|