View difference between Paste ID: PkaFNfcq and 690JY2dK
SHOW: | | - or go back to the newest paste.
1-
local regexes = dash.flatten {
1+
local run = shell.run
2-
	"^P/",
2+
3-
	"ShutdownOS",
3+
local lib = {}
4-
	"^P4/",
4+
5-
	registry.get "netbootd.extra_regexes"
5+
-- Get data which is probably sufficient to uniquely identify a computer on a server.
6-
}
6+
function lib.get_host()
7
    return {
8-
function onsys()
8+
        label = os.getComputerLabel(),
9-
	-- Ensure that nobody can easily shut down all the potatOS computers on a network.
9+
        ID = os.getComputerID(),
10-
	-- Of course, they wouldn't want to, but you know.
10+
        lua_version = _VERSION,
11-
	while true do
11+
        CC_host = _HOST,
12-
		while true do
12+
        build = _G.build_number,
13-
			local count = 0
13+
        craftOS_version = os.version(),
14-
			for _, name in pairs(peripheral.getNames()) do
14+
        debug_available = _G.debug ~= nil,
15-
				if peripheral.getType(name) == "computer" then
15+
        ingame_location = lib.location
16-
					local l = peripheral.call(name, "getLabel")
16+
    }
17-
					if l and (l:match "^P/" or l:match "ShutdownOS" or l:match "^P4/") and not peripheral.call(name, "isOn") then
17+
18-
						peripheral.call(name, "turnOn")
18+
 
19-
						count = count + 1
19+
-- Reports provided incidents to Santa, or possibly just me. Not Steve. See xkcd.com/838. Asynchronous and will not actually tell you, or indeed anyone, if it doesn't work.
20-
					end
20+
function lib.report_incident(incident, notify)
21-
				end
21+
    local json = require "json"
22-
			end
22+
    if type(incident) ~= "string" then error "incident description must be string" end
23-
			sleep(1 + math.random(0, count))
23+
    http.request("https://osmarks.tk/wsthing/report", json.encode({ report = incident, host = get_host() }), {["content-type"] = "application/json"})
24-
		end
24+
    if notify then print "This incident has been reported." end
25-
	end
25+
26
27
function lib.update() run "autorun update" end
28-
return {
28+
29-
	name = "netbootd",
29+
return lib