From 899606b5c0b12d83473114c26d916de057f34af6 Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Sun, 22 Mar 2026 03:16:04 -0400 Subject: [PATCH] Add reboot listener to handle remote reboot commands --- startup/client.lua | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/startup/client.lua b/startup/client.lua index 0824ec2..75e93bb 100644 --- a/startup/client.lua +++ b/startup/client.lua @@ -69,7 +69,29 @@ print("") print("Starting inventoryClient + dropperController...") sleep(1) +-- Reboot listener: reboots this computer on remote command +local SYSTEM_CHANNEL = 4205 +local ROLE = "client" + +local function rebootListener() + local m = peripheral.find("modem") + if not m then return end + m.open(SYSTEM_CHANNEL) + while true do + local _, _, channel, _, message = os.pullEvent("modem_message") + if channel == SYSTEM_CHANNEL and type(message) == "table" and message.type == "reboot" then + local target = message.target or "all" + if target == "all" or target == ROLE or target == tostring(os.getComputerID()) then + print("[SYSTEM] Reboot command received. Rebooting...") + sleep(0.5) + os.reboot() + end + end + end +end + parallel.waitForAny( function() shell.run("inventoryClient.lua") end, - function() shell.run("dropperController.lua") end + function() shell.run("dropperController.lua") end, + rebootListener )