From d90ce84cdb782f4a378b33fb427914880bd32e11 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Wed, 18 Mar 2020 01:31:44 +1100 Subject: [PATCH] made init actually work, whoops --- module/init.lua | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/module/init.lua b/module/init.lua index 7d09b36..a2f858e 100644 --- a/module/init.lua +++ b/module/init.lua @@ -8,6 +8,38 @@ --#include "module/devfs/syslog.lua" --#include "module/loadfile.lua" --#include "module/vt-task.lua" -os.spawnfile("/boot/exec/init.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 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 + pids[line] = -1 + end + f:close() + end + loadlist() + while true do + for k,v in pairs(pids) do + if not os.taskInfo(v) then + syslog("Starting service "..k) + pids[k] = os.spawnfile("/boot/service/"..k) + end + end + coroutine.yield() + end +end, "init") os.sched()