2019-10-27 23:34:02 +11:00
|
|
|
--#include "module/syslog.lua"
|
2019-10-27 02:40:25 +11:00
|
|
|
--#include "module/sched.lua"
|
2020-03-16 17:30:22 +11:00
|
|
|
--#include "module/buffer.lua"
|
2019-11-06 14:28:40 +11:00
|
|
|
--#include "module/osutil.lua"
|
2019-10-27 02:40:25 +11:00
|
|
|
--#include "module/fs.lua"
|
2020-03-16 17:30:22 +11:00
|
|
|
--#include "module/io.lua"
|
2019-10-27 23:34:02 +11:00
|
|
|
--#include "module/devfs.lua"
|
|
|
|
--#include "module/devfs/syslog.lua"
|
2023-07-31 08:11:24 +10:00
|
|
|
--#include "module/component-get.lua"
|
2019-10-27 02:40:25 +11:00
|
|
|
--#include "module/loadfile.lua"
|
2020-03-18 01:31:44 +11:00
|
|
|
|
2020-06-03 12:38:04 +10:00
|
|
|
_OSVERSION=_OSVERSION or "PsychOS 2"
|
|
|
|
|
2020-03-18 01:31:44 +11:00
|
|
|
os.spawn(function()
|
|
|
|
os.setenv("PWD","/boot")
|
|
|
|
io.input("/dev/null")
|
|
|
|
io.output("/dev/syslog")
|
|
|
|
local f = io.open("/boot/cfg/hostname","rb")
|
|
|
|
local hostname = computer.address():sub(1,8)
|
|
|
|
if f then
|
|
|
|
hostname = f:read("*l")
|
|
|
|
f:close()
|
|
|
|
end
|
|
|
|
os.setenv("HOSTNAME",hostname)
|
|
|
|
syslog(string.format("Hostname set to %s",hostname))
|
|
|
|
local pids = {}
|
2020-03-20 13:15:02 +11:00
|
|
|
local rc = require "rc"
|
|
|
|
for k,v in pairs(rc.cfg.enabled) do
|
|
|
|
pids[v] = -1
|
2020-03-18 01:31:44 +11:00
|
|
|
end
|
|
|
|
while true do
|
|
|
|
for k,v in pairs(pids) do
|
|
|
|
if not os.taskInfo(v) then
|
|
|
|
syslog("Starting service "..k)
|
2020-03-20 13:15:02 +11:00
|
|
|
pids[k] = rc.start(k)
|
2020-03-18 01:31:44 +11:00
|
|
|
end
|
|
|
|
end
|
|
|
|
coroutine.yield()
|
|
|
|
end
|
|
|
|
end, "init")
|
2019-10-27 23:34:02 +11:00
|
|
|
|
|
|
|
os.sched()
|