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.

35 lines
723B

  1. _OSVERSION=_OSVERSION or "PsychOS 2"
  2. os.spawn(function()
  3. os.setenv("PWD","/boot")
  4. io.input("/dev/null")
  5. io.output("/dev/syslog")
  6. local f = io.open("/boot/cfg/hostname","rb")
  7. local hostname = computer.address():sub(1,8)
  8. if f then
  9. hostname = f:read("*l")
  10. f:close()
  11. end
  12. os.setenv("HOSTNAME",hostname)
  13. syslog(string.format("Hostname set to %s",hostname))
  14. if fs.exists("/boot/pkg") then
  15. pcall(require,"pkgfs")
  16. end
  17. local pids = {}
  18. local rc = require "rc"
  19. for k,v in pairs(rc.cfg.enabled) do
  20. pids[v] = -1
  21. end
  22. while true do
  23. for k,v in pairs(pids) do
  24. if not os.taskInfo(v) then
  25. syslog("Starting service "..k)
  26. pids[k] = rc.start(k)
  27. end
  28. end
  29. coroutine.yield()
  30. end
  31. end, "init")
  32. os.sched()