42 lines
945 B
Lua
42 lines
945 B
Lua
--#include "module/syslog.lua"
|
|
--#include "module/sched.lua"
|
|
--#include "module/buffer.lua"
|
|
--#include "module/osutil.lua"
|
|
--#include "module/fs.lua"
|
|
--#include "module/io.lua"
|
|
--#include "module/devfs.lua"
|
|
--#include "module/devfs/syslog.lua"
|
|
--#include "module/loadfile.lua"
|
|
--#include "module/vt-task.lua"
|
|
|
|
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 = {}
|
|
local rc = require "rc"
|
|
for k,v in pairs(rc.cfg.enabled) do
|
|
pids[v] = -1
|
|
dprint(v)
|
|
end
|
|
while true do
|
|
for k,v in pairs(pids) do
|
|
if not os.taskInfo(v) then
|
|
syslog("Starting service "..k)
|
|
pids[k] = rc.start(k)
|
|
end
|
|
end
|
|
coroutine.yield()
|
|
end
|
|
end, "init")
|
|
|
|
os.sched()
|