From 8c98546fbfe83627ffe747e7f304a3b1c231a643 Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Sun, 22 Mar 2026 03:08:59 -0400 Subject: [PATCH] Add startup script for Web Bridge with auto-update functionality --- startup/bridge.lua | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 startup/bridge.lua diff --git a/startup/bridge.lua b/startup/bridge.lua new file mode 100644 index 0000000..4ede619 --- /dev/null +++ b/startup/bridge.lua @@ -0,0 +1,58 @@ +-- startup.lua for Web Bridge computer +-- Auto-updates from git then launches inventoryWebBridge.lua + +local REPO_RAW = "https://git.spatulaa.com/MayaTheShy/Inventory-Manager-CC/raw/branch/main" + +local FILES = { + ["inventoryWebBridge.lua"] = "inventoryWebBridge.lua", +} + +------------------------------------------------- + +local function download(remotePath, localPath) + local url = REPO_RAW .. "/" .. remotePath + local response = http.get(url) + if response then + local f = fs.open(localPath, "w") + f.write(response.readAll()) + f.close() + response.close() + return true + end + return false +end + +------------------------------------------------- + +term.clear() +term.setCursorPos(1, 1) +print("==================================") +print(" Web Bridge - Startup") +print(" Computer ID: " .. os.getComputerID()) +print("==================================") +print("") + +local updated, failed = 0, 0 +for localPath, remotePath in pairs(FILES) do + write(" " .. localPath .. " ... ") + if download(remotePath, localPath) then + print("OK") + updated = updated + 1 + else + print("FAIL") + failed = failed + 1 + end +end + +print("") +if failed > 0 then + print(string.format("Updated %d files, %d failed.", updated, failed)) +else + print(string.format("All %d files up to date.", updated)) +end + +print("") +print("Starting inventoryWebBridge...") +sleep(1) + +shell.run("inventoryWebBridge.lua")