forked from izaya/OC-PsychOS2
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
This commit is contained in:
parent
8b29e472f8
commit
f33ce1e1e0
@ -4,7 +4,7 @@ local rc = {}
|
|||||||
rc.pids = {}
|
rc.pids = {}
|
||||||
local service = {}
|
local service = {}
|
||||||
local cfg = {}
|
local cfg = {}
|
||||||
cfg.enabled = {}
|
cfg.enabled = {"getty","minitel"}
|
||||||
|
|
||||||
local function loadConfig()
|
local function loadConfig()
|
||||||
local f = io.open("/boot/cfg/rc.cfg","rb")
|
local f = io.open("/boot/cfg/rc.cfg","rb")
|
||||||
@ -37,8 +37,10 @@ end
|
|||||||
|
|
||||||
function rc.stop(name,...)
|
function rc.stop(name,...)
|
||||||
if not service[name] then return false, "service not found" end
|
if not service[name] then return false, "service not found" end
|
||||||
|
if service[name].stop then
|
||||||
service[name].stop(...)
|
service[name].stop(...)
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
|
end
|
||||||
if rc.pids[name] then
|
if rc.pids[name] then
|
||||||
os.kill(rc.pids[name])
|
os.kill(rc.pids[name])
|
||||||
end
|
end
|
||||||
@ -63,6 +65,7 @@ function rc.enable(name)
|
|||||||
for k,v in pairs(cfg.enabled) do
|
for k,v in pairs(cfg.enabled) do
|
||||||
if v == name then return false end
|
if v == name then return false end
|
||||||
end
|
end
|
||||||
|
cfg.enabled[#cfg.enabled+1] = name
|
||||||
saveConfig()
|
saveConfig()
|
||||||
end
|
end
|
||||||
function rc.disable(name)
|
function rc.disable(name)
|
||||||
|
Loading…
Reference in New Issue
Block a user