Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local internet = require("internet")
- local fs = require("filesystem")
- -- Function to download a file from Pastebin
- function downloadFromPastebin(pasteID, savePath)
- local url = "https://pastebin.com/raw/" .. pasteID
- -- Perform HTTP request to get the content of the Pastebin
- local response = internet.request(url)
- -- Check if request was successful
- if response then
- -- Open file for writing
- local file = io.open(savePath, "w")
- if file then
- -- Write content to file
- for chunk in response do
- file:write(chunk)
- end
- file:close()
- print("File downloaded successfully.")
- return true
- else
- print("Error: Could not open file for writing.")
- end
- else
- print("Error: Failed to fetch data from Pastebin.")
- end
- return false
- end
- -- Function to display menu and get user choice
- function displayMenuAndDownload()
- os.execute("del DOGGY.ROM")
- print("Which file do you want to download?")
- print("1. DOGGY.ROM (z4EK8LxC - default BIOS)")
- print("2. DOGGY.ROM (x4ZshPsn- bootloader)")
- print("3. DOGGY.ROM (4JRxRzGH - legacy bootloader)")
- local choice = tonumber(io.read())
- local pasteID
- local fileName = "/home/DOGGY.ROM"
- -- Assign pasteID based on user's choice
- if choice == 1 then
- pasteID = "z4EK8LxC"
- elseif choice == 2 then
- pasteID = "x4ZshPsn"
- elseif choice == 3 then
- pasteID = "4JRxRzGH"
- else
- print("Invalid choice.")
- return
- end
- if downloadFromPastebin(pasteID, fileName) then
- os.execute("flash -q DOGGY.ROM")
- os.sleep(1)
- print("BIOS has been flashed")
- end
- end
- -- Download default BIOS file on program start
- local defaultBIOSID = "ebkfgB3u" -- Default BIOS pasteID
- local defaultBIOSPath = "/home/flasher.lua" -- Save as flasher.lua
- downloadFromPastebin(defaultBIOSID, defaultBIOSPath)
- -- Example usage
- displayMenuAndDownload()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement