Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local configFile = "/disk/os/config.txt"
- local osVerification = false
- -- Function to check and load config settings
- local function loadConfig()
- if fs.exists(configFile) then
- local file = fs.open(configFile, "r")
- osVerification = (file.readLine() == "true")
- file.close()
- end
- end
- -- Function to display OS verification status
- local function displayVerificationStatus()
- term.clear()
- term.setCursorPos(1, 1)
- print("OS verification is " .. (osVerification and "enabled" or "disabled"))
- print("---------------------------------")
- end
- -- Function to unlock bootloader
- local function unlockBootloader()
- local startupContent = [[
- term.clear()
- term.setCursorPos(1, 1)
- print("VA11-ILLA bootloader unlocked")
- print("Doggy OS security has disabled, Boot Doggy OS?")
- print("------------------------------------------------------------")
- print("1. Yes")
- print("2. No")
- local choice = read()
- if choice == "1" then
- print("Booting kernel...")
- sleep(2)
- shell.run("/disk/os/gui")
- elseif choice == "2" then
- os.shutdown()
- end
- ]]
- local file = fs.open("/startup", "w")
- file.write(startupContent)
- file.close()
- -- Set OS verification to disabled after unlocking bootloader
- osVerification = false
- local config = fs.open(configFile, "w")
- config.write("false")
- config.close()
- end
- -- Function to lock bootloader
- local function lockBootloader()
- fs.copy("/recovery/boot/error", "/startup")
- end
- -- Function to enable OS verification
- local function enableOSVerification()
- term.clear()
- term.setCursorPos(1, 1)
- print("Enabling OS verification...")
- sleep(1)
- local file = fs.open(configFile, "w")
- file.write("true")
- file.close()
- print("OS verification enabled")
- sleep(1)
- -- Set OS verification to enabled after enabling OS verification
- osVerification = true
- end
- -- Function to run app with superuser permissions
- local function runWithSuperuser()
- term.clear()
- term.setCursorPos(1, 1)
- print("Type a file name:")
- local fileName = read()
- -- Display a message before running the app
- print("This application has full system access to your OS file system.")
- print("Run file: " .. fileName .. "? (yes/no)")
- local confirm = read()
- if confirm:lower() == "yes" then
- local success, errorMessage = pcall(function()
- shell.run("sudo", fileName)
- end)
- if not success then
- print("This operation has failed: " .. errorMessage)
- sleep(2)
- end
- else
- print("Operation canceled.")
- sleep(1)
- end
- end
- -- Main program
- while true do
- loadConfig()
- displayVerificationStatus()
- -- Show OS verification status and wait for Enter to display the menu
- print("Press Enter to continue...")
- while true do
- local _, key = os.pullEvent("key")
- if key == keys.enter then
- break
- end
- end
- displayMainMenu()
- local option = read()
- if option == "1" then
- unlockBootloader()
- elseif option == "2" then
- lockBootloader()
- elseif option == "3" then
- enableOSVerification()
- elseif option == "4" then
- runWithSuperuser()
- elseif option == "5" then
- print("Exiting...")
- sleep(1)
- term.clear()
- term.setCursorPos(1, 1)
- break
- else
- print("Invalid option.")
- sleep(1)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement