From eb1aa492126d80783b60f934e555acf1c8b3d5c1 Mon Sep 17 00:00:00 2001 From: Guillaume ARM Date: Tue, 19 Jul 2022 00:27:20 +0200 Subject: [PATCH] chore: update cube --- programs/cube.lua | 18 +++++++++++++----- servers/cube-server.lua | 5 ++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/programs/cube.lua b/programs/cube.lua index 69db858..d8e5397 100644 --- a/programs/cube.lua +++ b/programs/cube.lua @@ -10,6 +10,7 @@ local IGNORED_PATHS = { ['/.cubeboot'] = true, ['/.git'] = true, ['/.gitignore'] = true, + ['/startup.lua'] = true, } local function isValidPath(givenPath) @@ -149,7 +150,7 @@ end ------------ -- reboot -- ------------ -local function rebootCommand(machineId) +local function rebootCommand(machineId, silentReboot) if not machineId or machineId == '' then printUsageCommand('reboot'); return; @@ -164,7 +165,9 @@ local function rebootCommand(machineId) for k in ipairs(results) do local packet = packets[k]; - print('reboot machine \'' .. tostring(packet.sourceId) .. '\''); + if not silentReboot == true then + print('reboot machine \'' .. tostring(packet.sourceId) .. '\''); + end end end @@ -192,7 +195,12 @@ local function setBootCommand(machineId, shellCommand) print('boot UPDATED'); end - rebootCommand(packet.sourceId); + rebootCommand(packet.sourceId, true); + + -- prevent CraftOS-PC crashes + if periphemu then + os.sleep(0.5) + end end end @@ -240,9 +248,9 @@ local function deployCommand() end end - print('|> ' .. tostring(fileTransfered) .. ' file(s) transfered on machine ' .. tostring(machineId)) + print(tostring(fileTransfered) .. ' file(s) transfered on machine ' .. tostring(machineId)) - rebootCommand(machineId); + rebootCommand(machineId, true); -- prevent CraftOS-PC crashes if periphemu then diff --git a/servers/cube-server.lua b/servers/cube-server.lua index 186fc13..c9c5a2d 100644 --- a/servers/cube-server.lua +++ b/servers/cube-server.lua @@ -49,9 +49,8 @@ end) net.listenRequest(CUBE_CHANNEL, "reboot", function(_, reply) reply(true); - net.events.setTimeout(function() - os.reboot(); - end, 0.1); + os.sleep(0.2) + os.reboot() end) -- set-boot event