Advertisement
DOGGYWOOF

Untitled

Apr 27th, 2024 (edited)
6
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. local component = require("component")
  2. local internet = require("internet")
  3. local fs = require("filesystem")
  4.  
  5. -- Function to download a file from Pastebin
  6. function downloadFromPastebin(pasteID, savePath)
  7. local url = "https://pastebin.com/raw/" .. pasteID
  8.  
  9. -- Perform HTTP request to get the content of the Pastebin
  10. local response = internet.request(url)
  11.  
  12. -- Check if request was successful
  13. if response then
  14. -- Open file for writing
  15. local file = io.open(savePath, "w")
  16. if file then
  17. -- Write content to file
  18. for chunk in response do
  19. file:write(chunk)
  20. end
  21. file:close()
  22. print("File downloaded successfully.")
  23. return true
  24. else
  25. print("Error: Could not open file for writing.")
  26. end
  27. else
  28. print("Error: Failed to fetch data from Pastebin.")
  29. end
  30. return false
  31. end
  32.  
  33. -- Function to display menu and get user choice
  34. function displayMenuAndDownload()
  35. os.execute("del DOGGY.ROM")
  36. print("Which file do you want to download?")
  37. print("1. DOGGY.ROM (z4EK8LxC - default BIOS)")
  38. print("2. DOGGY.ROM (x4ZshPsn- bootloader)")
  39. print("3. DOGGY.ROM (4JRxRzGH - legacy bootloader)")
  40.  
  41. local choice = tonumber(io.read())
  42. local pasteID
  43. local fileName = "/home/DOGGY.ROM"
  44.  
  45. -- Assign pasteID based on user's choice
  46. if choice == 1 then
  47. pasteID = "z4EK8LxC"
  48. elseif choice == 2 then
  49. pasteID = "x4ZshPsn"
  50. elseif choice == 3 then
  51. pasteID = "4JRxRzGH"
  52. else
  53. print("Invalid choice.")
  54. return
  55. end
  56.  
  57. if downloadFromPastebin(pasteID, fileName) then
  58. os.execute("flash -q DOGGY.ROM")
  59. os.sleep(1)
  60. print("BIOS has been flashed")
  61. end
  62. end
  63.  
  64. -- Download default BIOS file on program start
  65. local defaultBIOSID = "ebkfgB3u" -- Default BIOS pasteID
  66. local defaultBIOSPath = "/home/flasher.lua" -- Save as flasher.lua
  67. downloadFromPastebin(defaultBIOSID, defaultBIOSPath)
  68.  
  69. -- Example usage
  70. displayMenuAndDownload()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement