feat: Add auto-update startup scripts for turtle, webbridge, and pocket computers
This commit is contained in:
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
|
||||
Reference in New Issue
Block a user