Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Doggy OS Systems
- -- DogRE 13.0 (N3K0 V13 CFG)
- local function clearScreen(message)
- term.clear()
- term.setCursorPos(1, 1)
- if message then
- print(message)
- end
- end
- local function waitForDisk(diskPath, message)
- clearScreen(message)
- while not fs.exists(diskPath) do
- sleep(1)
- end
- end
- local function promptForEnter(message)
- print(message .. " Press Enter to continue...")
- io.read() -- Wait for user to press Enter
- end
- local function askToOverride(filePath)
- clearScreen("File " .. filePath .. " already exists.\nDo you want to override it?\n1. Yes\n2. No (Skip)")
- local choice = tonumber(io.read())
- if choice == 1 then
- return true -- User wants to override
- else
- return false -- User wants to skip
- end
- end
- -- Enhanced error display
- local function displayError(errorMsg, errorCode)
- clearScreen("===== DOGGY OS SYSTEM RECOVERY ERROR =====")
- print("Error Message: " .. errorMsg)
- print("Error Code: DOSx7002")
- print("\nPossible Causes:")
- print("1. Missing or corrupted files.")
- print("2. Disk access errors.")
- print("3. Unexpected system behavior.")
- print("\nSuggested Actions:")
- print("1. Check disk connections and try again.")
- print("2. Run a full system recovery.")
- print("3. Contact support if the issue persists.\n")
- promptForEnter("Press Enter to Reboot system and return to normal system environment")
- end
- local function performAction(action, successMessage, failureMessage)
- clearScreen()
- local success, err = pcall(action)
- if success then
- print(successMessage)
- else
- displayError(failureMessage or "An unexpected error occurred.", err)
- end
- sleep(2)
- end
- -- Define showLoadingScreen function
- local function showLoadingScreen(message, totalSteps)
- local barLength = 30 -- Length of the loading bar
- clearScreen(message)
- for step = 1, totalSteps do
- term.setCursorPos(1, 3)
- write("[")
- for i = 1, barLength do
- if i <= math.floor((step / totalSteps) * barLength) then
- write("=") -- Progress part of the bar
- else
- write(" ") -- Empty part of the bar
- end
- end
- write("] " .. math.floor((step / totalSteps) * 100) .. "%")
- sleep(0.3) -- Slow down the animation for better visual effect
- end
- end
- -- Verify System Mode (Checks for issues but makes no fixes)
- local function verifySystem()
- clearScreen("Verifying system files...\nPlease wait...")
- local function checkFileIntegrity(sourceDir, targetDir, excludeDir)
- local files = fs.list(sourceDir)
- for _, file in ipairs(files) do
- local sourcePath = fs.combine(sourceDir, file)
- local targetPath = fs.combine(targetDir, file)
- if fs.isDir(sourcePath) then
- if not sourcePath:match(excludeDir) then
- checkFileIntegrity(sourcePath, targetPath, excludeDir)
- end
- else
- if not fs.exists(targetPath) then
- print("Missing file: " .. targetPath)
- end
- end
- end
- end
- checkFileIntegrity("/recovery", "/disk", "/disk/users")
- promptForEnter("Verification complete. No changes were made.")
- end
- local function fullSystemRecovery()
- performAction(
- function()
- local function checkAndCopyMissingFiles()
- local function copyFileIfMissing(sourcePath, targetPath)
- if not fs.exists(targetPath) then
- print("Copying missing file: " .. sourcePath)
- fs.copy(sourcePath, targetPath)
- else
- print("File already exists, skipping: " .. targetPath)
- end
- end
- local function checkDirectory(sourceDir, targetDir, excludeDir)
- local files = fs.list(sourceDir)
- for _, file in ipairs(files) do
- local sourcePath = fs.combine(sourceDir, file)
- local targetPath = fs.combine(targetDir, file)
- if fs.isDir(sourcePath) then
- if not sourcePath:match(excludeDir) then
- checkDirectory(sourcePath, targetPath, excludeDir)
- end
- else
- copyFileIfMissing(sourcePath, targetPath)
- end
- end
- end
- checkDirectory("/recovery", "/disk", "/disk/users")
- end
- checkAndCopyMissingFiles()
- end,
- "Full System Recovery completed."
- )
- showLoadingScreen("Doggy OS System Recovery...", 50)
- clearScreen("Recovery process completed.\nThe system is now restored.")
- promptForEnter("Press Enter to exit")
- end
- local function wipeDataAndResetFactoryDefaults()
- performAction(
- function()
- clearScreen("Wiping data and resetting to factory defaults...\nThis may take a while...")
- if fs.exists("/disk") then
- local function deleteDirContent(path, exclude)
- local files = fs.list(path)
- for _, file in ipairs(files) do
- local fullPath = fs.combine(path, file)
- if fs.isDir(fullPath) then
- if exclude and fullPath:sub(1, #exclude) == exclude then
- print("Skipping: " .. fullPath)
- else
- deleteDirContent(fullPath, exclude)
- end
- else
- fs.delete(fullPath)
- end
- end
- end
- deleteDirContent("/disk", "/disk/users")
- end
- if fs.exists("/.doggyfactorydefaults") then
- local function copyDirContent(source, destination)
- local files = fs.list(source)
- for _, file in ipairs(files) do
- local sourcePath = fs.combine(source, file)
- local destinationPath = fs.combine(destination, file)
- print("Copying: " .. sourcePath .. " -> " .. destinationPath)
- if fs.isDir(sourcePath) then
- if not fs.exists(destinationPath) then
- fs.makeDir(destinationPath)
- end
- copyDirContent(sourcePath, destinationPath)
- else
- fs.copy(sourcePath, destinationPath)
- end
- end
- end
- copyDirContent("/.doggyfactorydefaults", "/disk")
- else
- error("Error: /.doggyfactorydefaults not found.")
- end
- showLoadingScreen("Doggy OS Factory Reset...", 50)
- shell.run("/disk/setup")
- end,
- "Wipe data and reset to factory defaults completed."
- )
- end
- local function recoveryMenu()
- while true do
- clearScreen("===== Recovery Options =====\n1. Full System Recovery\n2. Wipe Data / Reset to Factory Defaults\n3. Verify System Integrity\n4. Exit")
- local choice = tonumber(io.read())
- if choice == 1 then
- fullSystemRecovery()
- elseif choice == 2 then
- wipeDataAndResetFactoryDefaults()
- elseif choice == 3 then
- verifySystem()
- elseif choice == 4 then
- break
- else
- clearScreen("Invalid choice. Please try again.")
- sleep(2)
- end
- end
- end
- local function powerMenu()
- clearScreen("===== Power Options =====\n1. Reboot system\n2. Shutdown system")
- local choice = tonumber(io.read())
- if choice == 1 then
- os.reboot()
- elseif choice == 2 then
- os.shutdown()
- else
- clearScreen("Invalid choice. Please try again.")
- sleep(2)
- end
- end
- local function mainMenu()
- while true do
- clearScreen("===== Doggy OS DEV Recovery GUI =====\n1. Recovery Options\n2. Power Options\n3. Exit")
- local choice = tonumber(io.read())
- if choice == 1 then
- recoveryMenu()
- elseif choice == 2 then
- powerMenu()
- else
- break
- end
- end
- end
- if fs.exists("/disk/config/dogRE/disableRE.cfg") then
- clearScreen("===== DOGGY OS SYSTEM RECOVERY ERROR =====")
- print("Error Message: " .. "Recovery Environment Disabled")
- print("Error Code: DOSx7000")
- print("\nPossible Causes:")
- print("1. Recovery Environment has been disabled by your system administrator")
- print("2. Malware or unwanted software disabled DogRE")
- print("3. System config errors or corruption")
- print("\nSuggested Actions:")
- print("1. Reboot the computer and re-enable DogRE")
- print("2. Reinstall Doggy OS or rebuild the recovery partition")
- print("3. Contact support if the issue persists.\n")
- promptForEnter("Press Enter to Reboot system and return to normal system environment")
- else
- if fs.exists ("/recovery")
- then
- mainMenu()
- else
- displayError("Recovery Environment Failed to load", "DOSx7002")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement