Operating system for OpenComputers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
554B

  1. if os.taskInfo(1) then
  2. return false, "init already started"
  3. end
  4. os.setenv("PWD","/boot")
  5. io.input("/dev/null")
  6. io.output("/dev/syslog")
  7. local pids = {}
  8. local function loadlist()
  9. local f = io.open("/boot/cfg/init.txt","rb")
  10. if not f then return false end
  11. for line in f:read("*a"):gmatch("[^\r\n]+") do
  12. dprint(line)
  13. pids[line] = -1
  14. end
  15. f:close()
  16. end
  17. loadlist()
  18. while true do
  19. for k,v in pairs(pids) do
  20. if not os.taskInfo(v) then
  21. dprint("Starting service "..k)
  22. pids[k] = os.spawnfile("/boot/service/"..k)
  23. end
  24. end
  25. coroutine.yield()
  26. end