Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Doggy OS Recovery
- local function clearScreen()
- term.clear()
- term.setCursorPos(1, 1)
- end
- local function drawBorder()
- term.setCursorPos(1, 1)
- term.write(string.rep("=", term.getSize()))
- term.setCursorPos(1, select(2, term.getSize()))
- term.write(string.rep("=", term.getSize()))
- end
- local function displayMenu(title, options)
- clearScreen()
- drawBorder()
- term.setCursorPos(1, 2)
- print(string.rep(" ", math.floor((term.getSize() - #title) / 2)) .. title)
- print()
- for i, option in ipairs(options) do
- print(" " .. i .. ". " .. option)
- end
- print()
- print("Enter your choice:")
- end
- local function backupUsersFolder()
- if fs.exists("/disk/users/") then
- shell.run("delete /backup_users")
- shell.run("copy /disk/users /backup_users")
- print("Users folder backed up.")
- end
- end
- local function restoreUsersFolder()
- if fs.exists("/backup_users/") then
- shell.run("delete /disk/users")
- shell.run("copy /backup_users /disk/users")
- shell.run("delete /backup_users")
- print("Users folder restored.")
- end
- end
- local function fullSystemRecovery()
- clearScreen()
- backupUsersFolder()
- shell.run("delete /disk")
- shell.run("copy /recovery /disk")
- restoreUsersFolder()
- print("Full System Recovery completed.")
- sleep(2)
- end
- local function refreshRecoveryPartition()
- clearScreen()
- print("Please insert Doggy OS disk!")
- while not fs.exists("/disk2/") do
- sleep(1)
- end
- shell.run("delete /recovery")
- shell.run("copy /disk2 /recovery")
- print("Recovery partition refreshed.")
- sleep(2)
- end
- local function installUpdateFromDisk()
- clearScreen()
- print("Please insert Doggy OS disk!")
- while not fs.exists("/disk2/") do
- sleep(1)
- end
- backupUsersFolder()
- shell.run("delete /disk")
- shell.run("copy /disk2 /disk")
- restoreUsersFolder()
- print("Update installed from disk.")
- sleep(2)
- end
- local function overrideBootloader()
- clearScreen()
- print("Override Bootloader:")
- print("Enter the location of the OS kernel:")
- local kernelLocation = io.read()
- if fs.exists(kernelLocation) then
- shell.run("delete /startup")
- shell.run("copy " .. kernelLocation .. " /startup")
- print("Bootloader overridden successfully.")
- else
- print("Error: Specified file not found.")
- end
- sleep(2)
- end
- -- Main loop
- while true do
- displayMenu("Doggy OS Emergency System Recovery GUI", {"Recovery Options", "Power Options"})
- local choice = tonumber(io.read())
- if choice == 1 then
- while true do
- displayMenu("Recovery Options", {"Full System Recovery", "Refresh Recovery Partition", "Install Update from Disk", "Override Bootloader", "Back"})
- local recoveryChoice = tonumber(io.read())
- if recoveryChoice == 1 then
- fullSystemRecovery()
- elseif recoveryChoice == 2 then
- refreshRecoveryPartition()
- elseif recoveryChoice == 3 then
- installUpdateFromDisk()
- elseif recoveryChoice == 4 then
- overrideBootloader()
- elseif recoveryChoice == 5 then
- break
- else
- print("Invalid choice.")
- sleep(2)
- end
- end
- elseif choice == 2 then
- displayMenu("Power Options", {"Reboot system", "Shutdown system"})
- local powerChoice = tonumber(io.read())
- if powerChoice == 1 then
- os.reboot()
- elseif powerChoice == 2 then
- os.shutdown()
- else
- print("Invalid choice.")
- sleep(2)
- end
- else
- print("Invalid choice. Please try again.")
- sleep(2)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement