TheDarBear

reboot

Aug 20th, 2025 (edited)
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. -- reboot.lua
  2. -- 1) wipe everything except /rom
  3. -- 2) pastebin get 7jWUHDLX it
  4. -- 3) run it
  5.  
  6. local function wipe_all_but_rom()
  7. local entries = fs.list("/")
  8. for _, name in ipairs(entries) do
  9. if name ~= "rom" then
  10. local path = "/" .. name
  11. -- fs.delete is recursive for directories
  12. pcall(fs.delete, path)
  13. end
  14. end
  15. end
  16.  
  17. local function pastebin_get(id, out)
  18. -- Prefer shell.execute (returns ok, reason) if present; fallback to shell.run (bool)
  19. if shell.execute then
  20. local ok, reason = shell.execute("pastebin", "get", id, out)
  21. if not ok then error("pastebin get failed: " .. tostring(reason)) end
  22. else
  23. local ok = shell.run("pastebin", "get", id, out)
  24. if not ok then error("pastebin get failed (is HTTP enabled?)") end
  25. end
  26. end
  27.  
  28. local function run_file(path)
  29. -- Run as a program so it gets its own environment
  30. local ok, reason = shell.run(path)
  31. if not ok then error("failed to run " .. path .. ": " .. tostring(reason)) end
  32. end
  33.  
  34. -- ---------- main ----------
  35. print("Wiping filesystem (except /rom)...")
  36. wipe_all_but_rom()
  37.  
  38. print("Downloading init from Pastebin...")
  39. pastebin_get("7jWUHDLX", "init")
  40.  
  41. print("Running init...")
  42. run_file("init")
  43.  
Advertisement
Add Comment
Please, Sign In to add comment