Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function clearScreen()
- term.clear()
- term.setCursorPos(1, 1)
- end
- local function readConfig()
- local file = fs.open("/config.txt", "r")
- if file then
- local content = file.readAll()
- file.close()
- return content
- end
- return ""
- end
- local function writeConfig(content)
- local file = fs.open("/config.txt", "w")
- if file then
- file.write(content)
- file.close()
- end
- end
- local function setSecurityPassword()
- clearScreen()
- print("Enter the new security password:")
- local newPassword = io.read()
- writeConfig(newPassword)
- print("Security password set successfully.")
- sleep(2)
- end
- local function removeSecurityPassword()
- clearScreen()
- local content = readConfig()
- if content ~= "false" then
- writeConfig("false")
- print("Security password removed successfully.")
- else
- print("No security password set. Unable to remove.")
- end
- sleep(2)
- end
- local function resetSecurityPassword()
- clearScreen()
- local content = readConfig()
- if content ~= "false" then
- print("Enter the new security password:")
- local newPassword = io.read()
- writeConfig(newPassword)
- print("Security password reset successfully.")
- else
- print("No security password set. Unable to reset.")
- end
- sleep(2)
- end
- local function fullSystemRecovery()
- clearScreen()
- shell.run("delete /disk")
- shell.run("copy /recovery /disk")
- print("Full System Recovery completed.")
- sleep(2) -- Adding a delay for visibility
- 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) -- Adding a delay for visibility
- end
- local function installUpdateFromDisk()
- clearScreen()
- print("Please insert Doggy OS disk!")
- while not fs.exists("/disk2/") do
- sleep(1)
- end
- shell.run("delete /disk")
- shell.run("copy /disk2 /disk")
- print("Update installed from disk.")
- sleep(2) -- Adding a delay for visibility
- end
- -- Main loop
- while true do
- clearScreen()
- print("Doggy OS Main Menu:")
- print("1. Recovery Options")
- print("2. Power Options")
- print("3. Security")
- local mainChoice = tonumber(io.read())
- if mainChoice == 1 then
- while true do
- clearScreen()
- term.setCursorPos(1, 1)
- print("Recovery Options:")
- print("1. Full System Recovery")
- print("2. Refresh Recovery Partition")
- print("3. Install Update from Disk")
- print("4. 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
- break -- Go back to the main menu
- else
- print("Invalid choice.")
- sleep(2) -- Adding a delay for visibility
- end
- end
- elseif mainChoice == 2 then
- clearScreen()
- term.setCursorPos(1, 1)
- print("Power Options:")
- print("1. Reboot system")
- print("2. 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) -- Adding a delay for visibility
- end
- elseif mainChoice == 3 then
- while true do
- clearScreen()
- term.setCursorPos(1, 1)
- print("Security Options:")
- print("1. Set Security Password")
- print("2. Remove Security Password")
- print("3. Reset Security Password")
- print("4. Back")
- local securityChoice = tonumber(io.read())
- if securityChoice == 1 then
- setSecurityPassword()
- elseif securityChoice == 2 then
- removeSecurityPassword()
- elseif securityChoice == 3 then
- resetSecurityPassword()
- elseif securityChoice == 4 then
- break -- Go back to the main menu
- else
- print("Invalid choice.")
- sleep(2) -- Adding a delay for visibility
- end
- end
- else
- print("Invalid choice. Please try again.")
- sleep(2) -- Adding a delay for visibility
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement