1
1
mirror of https://git.shadowkat.net/izaya/OC-PsychOS2.git synced 2024-11-22 12:04:20 -05:00

rewrote init.lua to be a real init daemon

This commit is contained in:
XeonSquared 2019-11-09 14:23:18 +11:00
parent 1bd18f45b3
commit 6ad6880a6d
3 changed files with 26 additions and 16 deletions

View File

@ -1,9 +1,11 @@
#!/bin/sh #!/bin/sh
rm -r target/* rm -r target/*
mkdir target mkdir target &>/dev/null
mkdir target/cfg
lua luapreproc.lua module/init.lua target/init.lua lua luapreproc.lua module/init.lua target/init.lua
echo _OSVERSION=\"PsychOS 2.0a1-$(git rev-parse --short HEAD)\" > target/version.lua echo _OSVERSION=\"PsychOS 2.0a1-$(git rev-parse --short HEAD)\" > target/version.lua
cat target/version.lua target/init.lua > target/tinit.lua cat target/version.lua target/init.lua > target/tinit.lua
mv target/tinit.lua target/init.lua mv target/tinit.lua target/init.lua
cp -r exec/ service/ lib/ target/ cp -r exec/ service/ lib/ target/
cp default-init.txt target/cfg/
lua finddesc.lua $(find module/ -type f) $(find lib/ -type f) > apidoc.md lua finddesc.lua $(find module/ -type f) $(find lib/ -type f) > apidoc.md

View File

@ -1,3 +1 @@
minitel.lua getty.lua
tape-iofs.lua
fsmanager.service

View File

@ -1,16 +1,26 @@
xpcall(function() if os.taskInfo(1) then
return false, "init already started"
end
os.setenv("PWD","/boot") os.setenv("PWD","/boot")
os.spawnfile("/boot/service/getty.lua") io.input("/dev/null")
coroutine.yield() io.output("/dev/syslog")
for k,v in pairs(fs.list("/dev/")) do local pids = {}
if v:sub(1,3) == "tty" then local function loadlist()
dprint(tostring(io.input("/dev/"..v))) local f = io.open("/boot/cfg/init.txt","rb")
dprint(tostring(io.output("/dev/"..v))) if not f then return false end
print(_OSVERSION.." - "..tostring(math.floor(computer.totalMemory()/1024)).."K RAM") for line in f:read("*a"):gmatch("[^\r\n]+") do
os.spawnfile("/boot/exec/shell.lua") dprint(line)
pids[line] = -1
end end
f:close()
end end
loadlist()
while true do while true do
for k,v in pairs(pids) do
if not os.taskInfo(v) then
dprint("Starting service "..k)
pids[k] = os.spawnfile("/boot/service/"..k)
end
end
coroutine.yield() coroutine.yield()
end end
end,function(e) dprint(e) end,"init")