From 544c5be954af5350360562b95caa0308af2582ca Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Fri, 20 Feb 2026 00:23:03 -0500 Subject: [PATCH] feat: Add auto-update startup scripts for turtle, webbridge, and pocket computers --- STARTUP_README.md | 65 +++++++++++++++++++++++++++++++++++++++++++ startup_pocket.lua | 56 +++++++++++++++++++++++++++++++++++++ startup_turtle.lua | 56 +++++++++++++++++++++++++++++++++++++ startup_webbridge.lua | 56 +++++++++++++++++++++++++++++++++++++ 4 files changed, 233 insertions(+) create mode 100644 STARTUP_README.md create mode 100644 startup_pocket.lua create mode 100644 startup_turtle.lua create mode 100644 startup_webbridge.lua diff --git a/STARTUP_README.md b/STARTUP_README.md new file mode 100644 index 0000000..c6e19ad --- /dev/null +++ b/STARTUP_README.md @@ -0,0 +1,65 @@ +# Auto-Update Startup Scripts + +These scripts automatically download and run the latest versions of your turtle control programs when computers start up. + +## Installation + +### For Turtles: +```lua +wget https://git.spatulaa.com/MayaTheShy/remoteturtle/raw/branch/master/startup_turtle.lua startup +``` + +### For Webbridge Computer: +```lua +wget https://git.spatulaa.com/MayaTheShy/remoteturtle/raw/branch/master/startup_webbridge.lua startup +``` + +### For Pocket Computer: +```lua +wget https://git.spatulaa.com/MayaTheShy/remoteturtle/raw/branch/master/startup_pocket.lua startup +``` + +## How It Works + +1. **On boot**, the startup script runs automatically +2. **Removes** the old version of the main script +3. **Downloads** the latest version from git +4. **Executes** the downloaded script + +## Fallback Behavior + +If the download fails (no internet, wrong URL, etc.): +- Shows an error message +- Attempts to run the existing version if available +- Shows manual download instructions + +## Benefits + +✅ Always run the latest version +✅ No manual script management +✅ Just reboot to update +✅ Fallback to existing version if offline +✅ Clear status messages + +## Manual Update + +To force an update on a running computer: +```lua +reboot +``` + +## Changing the URL + +If you need to change the git URL, edit the `SCRIPT_URL` variable in the startup script: +```lua +local SCRIPT_URL = "https://your-git-url-here/script.lua" +``` + +## Disabling Auto-Update + +To disable auto-update and use manual management: +```lua +rm startup +``` + +Then download scripts manually as needed. diff --git a/startup_pocket.lua b/startup_pocket.lua new file mode 100644 index 0000000..3dd5a67 --- /dev/null +++ b/startup_pocket.lua @@ -0,0 +1,56 @@ +-- Pocket Control Startup Script +-- Automatically downloads and runs the latest pocketcontrol.lua from git + +local SCRIPT_URL = "https://git.spatulaa.com/MayaTheShy/remoteturtle/raw/branch/master/pocketcontrol.lua" +local SCRIPT_NAME = "pocketcontrol.lua" + +print("========================================") +print(" POCKET CONTROL AUTO-UPDATER") +print("========================================") +print("") + +-- Remove old version +if fs.exists(SCRIPT_NAME) then + print("Removing old version...") + fs.delete(SCRIPT_NAME) +end + +-- Download latest version +print("Downloading latest version...") +print("URL: " .. SCRIPT_URL) + +local response = http.get(SCRIPT_URL) +if response then + local content = response.readAll() + response.close() + + -- Save to file + local file = fs.open(SCRIPT_NAME, "w") + file.write(content) + file.close() + + print("✓ Download successful!") + print("") + print("Starting pocket control...") + sleep(1) + + -- Run the script + shell.run(SCRIPT_NAME) +else + print("✗ Download failed!") + print("Please check:") + print(" - Internet connection") + print(" - URL is correct") + print(" - HTTP API is enabled") + print("") + print("Falling back to existing script...") + + -- Try to run existing version if download fails + if fs.exists(SCRIPT_NAME) then + shell.run(SCRIPT_NAME) + else + print("No existing script found!") + print("Please download manually:") + print(" wget " .. SCRIPT_URL .. " " .. SCRIPT_NAME) + end +end diff --git a/startup_turtle.lua b/startup_turtle.lua new file mode 100644 index 0000000..1e97d96 --- /dev/null +++ b/startup_turtle.lua @@ -0,0 +1,56 @@ +-- Turtle Startup Script +-- Automatically downloads and runs the latest turtle.lua from git + +local SCRIPT_URL = "https://git.spatulaa.com/MayaTheShy/remoteturtle/raw/branch/master/turtle.lua" +local SCRIPT_NAME = "turtle.lua" + +print("========================================") +print(" TURTLE AUTO-UPDATER") +print("========================================") +print("") + +-- Remove old version +if fs.exists(SCRIPT_NAME) then + print("Removing old version...") + fs.delete(SCRIPT_NAME) +end + +-- Download latest version +print("Downloading latest version...") +print("URL: " .. SCRIPT_URL) + +local response = http.get(SCRIPT_URL) +if response then + local content = response.readAll() + response.close() + + -- Save to file + local file = fs.open(SCRIPT_NAME, "w") + file.write(content) + file.close() + + print("✓ Download successful!") + print("") + print("Starting turtle program...") + sleep(1) + + -- Run the script + shell.run(SCRIPT_NAME) +else + print("✗ Download failed!") + print("Please check:") + print(" - Internet connection") + print(" - URL is correct") + print(" - HTTP API is enabled") + print("") + print("Falling back to existing script...") + + -- Try to run existing version if download fails + if fs.exists(SCRIPT_NAME) then + shell.run(SCRIPT_NAME) + else + print("No existing script found!") + print("Please download manually:") + print(" wget " .. SCRIPT_URL .. " " .. SCRIPT_NAME) + end +end diff --git a/startup_webbridge.lua b/startup_webbridge.lua new file mode 100644 index 0000000..c39718a --- /dev/null +++ b/startup_webbridge.lua @@ -0,0 +1,56 @@ +-- Webbridge Startup Script +-- Automatically downloads and runs the latest webbridge.lua from git + +local SCRIPT_URL = "https://git.spatulaa.com/MayaTheShy/remoteturtle/raw/branch/master/webbridge.lua" +local SCRIPT_NAME = "webbridge.lua" + +print("========================================") +print(" WEBBRIDGE AUTO-UPDATER") +print("========================================") +print("") + +-- Remove old version +if fs.exists(SCRIPT_NAME) then + print("Removing old version...") + fs.delete(SCRIPT_NAME) +end + +-- Download latest version +print("Downloading latest version...") +print("URL: " .. SCRIPT_URL) + +local response = http.get(SCRIPT_URL) +if response then + local content = response.readAll() + response.close() + + -- Save to file + local file = fs.open(SCRIPT_NAME, "w") + file.write(content) + file.close() + + print("✓ Download successful!") + print("") + print("Starting webbridge program...") + sleep(1) + + -- Run the script + shell.run(SCRIPT_NAME) +else + print("✗ Download failed!") + print("Please check:") + print(" - Internet connection") + print(" - URL is correct") + print(" - HTTP API is enabled") + print("") + print("Falling back to existing script...") + + -- Try to run existing version if download fails + if fs.exists(SCRIPT_NAME) then + shell.run(SCRIPT_NAME) + else + print("No existing script found!") + print("Please download manually:") + print(" wget " .. SCRIPT_URL .. " " .. SCRIPT_NAME) + end +end