57 lines
1.5 KiB
Lua
57 lines
1.5 KiB
Lua
-- 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
|