Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Paths
- local legacyConfigPath = "legacy.cfg"
- local recoveryPath = "/recovery"
- local dosRecoveryPath = "/DOS-RECOVERY"
- local errorFile = "/disk/boot/error"
- local startupFile = "/disk/boot/startup"
- local driveloadFile = "/disk/boot/driveload.exe"
- local startupLuaFile = "/disk/boot/startup.lua" -- New bootable file
- -- Functions
- local function fileExists(path)
- return fs.exists(path)
- end
- local function renameDirectory(oldPath, newPath)
- if fs.exists(oldPath) then
- fs.move(oldPath, newPath)
- end
- end
- -- Function to display error screen
- local function displayErrorScreen()
- term.clear()
- term.setCursorPos(1, 1)
- print("BOOTLOADER ERROR: NO FILE FOUND")
- print("")
- print(" _________________")
- print(" | | ___________ |o|")
- print(" | | ___________ | |")
- print(" | | ___________ | |")
- print(" | | ___________ | |")
- print(" | |_____________| |")
- print(" | _______ |")
- print(" | | | ||")
- print(" | DD | | V|")
- print(" |____|_______|____|")
- print("")
- print("Press F1 to disable Legacy Boot")
- print("Press F10 to Attempt boot again")
- print("Press F8 to reboot system")
- print("Press F9 to search for Doggy OS Bootable drives")
- end
- -- Main Logic
- if fileExists(legacyConfigPath) then
- -- Rename /recovery to /DOS-RECOVERY
- renameDirectory(recoveryPath, dosRecoveryPath)
- -- Display ASCII art and message
- term.clear()
- term.setCursorPos(1, 1)
- print("Doggy OS Legacy Bootloader")
- print("")
- print(" _________________")
- print(" | | ___________ |o|")
- print(" | | ___________ | |")
- print(" | | ___________ | |")
- print(" | | ___________ | |")
- print(" | |_____________| |")
- print(" | _______ |")
- print(" | | | ||")
- print(" | DD | | V|")
- print(" |____|_______|____|")
- print("")
- print("Press F1 to disable legacy boot")
- print("Press F10 to run boot file")
- -- Wait for key press
- local event, key
- repeat
- event, key = os.pullEvent("key")
- until key == keys.f1 or key == keys.f10
- -- Handle key presses
- if key == keys.f1 then
- print("Disabling legacy boot...")
- -- Rename /DOS-RECOVERY back to /recovery
- renameDirectory(dosRecoveryPath, recoveryPath)
- -- Reboot the system
- os.reboot()
- elseif key == keys.f10 then
- print("Running boot file...")
- -- Check and run startup.lua as a bootable file
- if fileExists(startupLuaFile) then
- shell.run(startupLuaFile)
- else
- -- Display error screen
- displayErrorScreen()
- -- Wait for key press on error screen
- repeat
- event, key = os.pullEvent("key")
- until key == keys.f1 or key == keys.f8 or key == keys.f9 or key == keys.f10
- -- Handle key presses on error screen
- if key == keys.f1 then
- print("Disabling legacy boot...")
- -- Rename /DOS-RECOVERY back to /recovery
- renameDirectory(dosRecoveryPath, recoveryPath)
- -- Reboot the system
- os.reboot()
- elseif key == keys.f8 then
- print("Rebooting system...")
- -- Reboot the system
- os.reboot()
- elseif key == keys.f9 then
- print("Searching for Doggy OS Bootable drives...")
- -- Perform search for bootable drives (add your logic here)
- -- For demonstration, let's assume we print a message
- print("No Doggy OS Bootable drives found.")
- elseif key == keys.f10 then
- print("Attempting boot again...")
- -- Check and run other boot files
- if fileExists(errorFile) then
- shell.run(errorFile)
- end
- if fileExists(startupFile) then
- shell.run(startupFile)
- end
- if fileExists(driveloadFile) then
- shell.run(driveloadFile)
- end
- end
- end
- end
- else
- -- Display error screen if legacy.cfg does not exist
- displayErrorScreen()
- -- Wait for key press on error screen
- repeat
- event, key = os.pullEvent("key")
- until key == keys.f1 or key == keys.f8 or key == keys.f9 or key == keys.f10
- -- Handle key presses on error screen
- if key == keys.f1 then
- print("Disabling legacy boot...")
- -- Reboot the system
- os.reboot()
- elseif key == keys.f8 then
- print("Rebooting system...")
- -- Reboot the system
- os.reboot()
- elseif key == keys.f9 then
- print("Searching for Doggy OS Bootable drives...")
- -- Perform search for bootable drives (add your logic here)
- -- For demonstration, let's assume we print a message
- print("No Doggy OS Bootable drives found.")
- elseif key == keys.f10 then
- print("Attempting boot again...")
- -- Check and run other boot files
- if fileExists(errorFile) then
- shell.run(errorFile)
- end
- if fileExists(startupFile) then
- shell.run(startupFile)
- end
- if fileExists(driveloadFile) then
- shell.run(driveloadFile)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement