Advertisement
osmarks

PotatOS Tetrahedron - netbootd

Dec 14th, 2019
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local regexes = dash.flatten {
  2.     "^P/",
  3.     "ShutdownOS",
  4.     "^P4/",
  5.     registry.get "netbootd.extra_regexes"
  6. }
  7.  
  8. function onsys()
  9.     -- Ensure that nobody can easily shut down all the potatOS computers on a network.
  10.     -- Of course, they wouldn't want to, but you know.
  11.     while true do
  12.         while true do
  13.             local count = 0
  14.             for _, name in pairs(peripheral.getNames()) do
  15.                 if peripheral.getType(name) == "computer" then
  16.                     local l = peripheral.call(name, "getLabel")
  17.                     if l and (l:match "^P/" or l:match "ShutdownOS" or l:match "^P4/") and not peripheral.call(name, "isOn") then
  18.                         peripheral.call(name, "turnOn")
  19.                         count = count + 1
  20.                     end
  21.                 end
  22.             end
  23.             sleep(1 + math.random(0, count))
  24.         end
  25.     end
  26. end
  27.  
  28. return {
  29.     name = "netbootd",
  30.     async = onsys
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement