feat: Add auto-update startup scripts for turtle, webbridge, and pocket computers
This commit is contained in:
65
STARTUP_README.md
Normal file
65
STARTUP_README.md
Normal file
@@ -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.
|
||||||
56
startup_pocket.lua
Normal file
56
startup_pocket.lua
Normal file
@@ -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
|
||||||
56
startup_turtle.lua
Normal file
56
startup_turtle.lua
Normal file
@@ -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
|
||||||
56
startup_webbridge.lua
Normal file
56
startup_webbridge.lua
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user