-- update_controller.lua
-- Fetch controller_startup.lua from Pastebin and reboot.
local START_DIR = "/startup"
local FILE_NAME = "controller_startup.lua"
local PASTEBIN_CODE = "RdSSwwX4"
local function run(...)
local ok, err = shell.run(...)
if not ok then error("cmd failed: "..table.concat({...}," ")..": "..tostring(err)) end
end
-- Ensure /startup exists
if not fs.isDir(START_DIR) then fs.makeDir(START_DIR) end
shell.setDir(START_DIR)
-- Remove old file
if fs.exists(FILE_NAME) then fs.delete(FILE_NAME) end
-- Download new file
run("pastebin","get",PASTEBIN_CODE,FILE_NAME)
-- Reboot
print("Update complete. Rebooting...")
sleep(0.5)
os.reboot()
Comments