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.

32 lines
661B

  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. local pids = {}
  15. local rc = require "rc"
  16. for k,v in pairs(rc.cfg.enabled) do
  17. pids[v] = -1
  18. end
  19. while true do
  20. for k,v in pairs(pids) do
  21. if not os.taskInfo(v) then
  22. syslog("Starting service "..k)
  23. pids[k] = rc.start(k)
  24. end
  25. end
  26. coroutine.yield()
  27. end
  28. end, "init")
  29. os.sched()