1
1
mirror of https://git.shadowkat.net/izaya/OC-PsychOS2.git synced 2024-12-27 04:53:22 -05:00
OC-PsychOS2/module/init.lua

46 lines
1.1 KiB
Lua
Raw Normal View History

2019-10-27 08:34:02 -04:00
--#include "module/syslog.lua"
2019-10-26 11:40:25 -04:00
--#include "module/sched.lua"
--#include "module/buffer.lua"
--#include "module/osutil.lua"
2019-10-26 11:40:25 -04:00
--#include "module/fs.lua"
--#include "module/io.lua"
2019-10-27 08:34:02 -04:00
--#include "module/devfs.lua"
--#include "module/devfs/syslog.lua"
2019-10-26 11:40:25 -04:00
--#include "module/loadfile.lua"
2020-03-17 10:11:53 -04:00
--#include "module/vt-task.lua"
2020-03-17 10:31:44 -04: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 = {}
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")
2019-10-27 08:34:02 -04:00
os.sched()