From f33ce1e1e018f924ba7018f6f58970894619901a Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Thu, 26 Mar 2020 17:32:54 +1100 Subject: [PATCH] added default services to rc, made rc.stop cope if there is no stop function in a daemon, and rc.enable actually enables things now --- lib/rc.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/rc.lua b/lib/rc.lua index e9ae788..16628db 100644 --- a/lib/rc.lua +++ b/lib/rc.lua @@ -4,7 +4,7 @@ local rc = {} rc.pids = {} local service = {} local cfg = {} -cfg.enabled = {} +cfg.enabled = {"getty","minitel"} local function loadConfig() local f = io.open("/boot/cfg/rc.cfg","rb") @@ -37,8 +37,10 @@ end function rc.stop(name,...) if not service[name] then return false, "service not found" end - service[name].stop(...) - coroutine.yield() + if service[name].stop then + service[name].stop(...) + coroutine.yield() + end if rc.pids[name] then os.kill(rc.pids[name]) end @@ -63,6 +65,7 @@ function rc.enable(name) for k,v in pairs(cfg.enabled) do if v == name then return false end end + cfg.enabled[#cfg.enabled+1] = name saveConfig() end function rc.disable(name)