Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to draw a border with a title
- local function drawBorderWithTitle(title)
- term.clear()
- local w, h = term.getSize()
- for y = 1, h do
- term.setCursorPos(1, y)
- term.write("|")
- term.setCursorPos(w, y)
- term.write("|")
- end
- for x = 1, w do
- term.setCursorPos(x, 1)
- term.write("-")
- term.setCursorPos(x, h)
- term.write("-")
- end
- term.setCursorPos(1, 1)
- term.write("+")
- term.setCursorPos(w, 1)
- term.write("+")
- term.setCursorPos(1, h)
- term.write("+")
- term.setCursorPos(w, h)
- term.write("+")
- -- Center the title
- local x = math.floor((w - #title) / 2) + 1
- term.setCursorPos(x, 1)
- term.write("[" .. title .. "]")
- end
- -- Function to center text on the screen
- local function centerText(text, y)
- local w, _ = term.getSize()
- local x = math.floor((w - #text) / 2) + 1
- term.setCursorPos(x, y)
- term.write(text)
- end
- -- Function to verify the recovery key
- local function verifyRecoveryKey()
- local keyPath = "/disk/security/RecoveryKey.txt"
- if fs.exists(keyPath) then
- local file = fs.open(keyPath, "r")
- local storedKey = file.readAll()
- file.close()
- term.clear()
- drawBorderWithTitle("Doggy OS System Security")
- centerText("Recovery key needed to regain access", 3)
- centerText("", 5)
- term.setCursorPos(10, 7)
- term.write("Enter Key: ")
- local enteredKey = read()
- if enteredKey == storedKey then
- centerText("Unlocking device...", 10)
- os.sleep(2)
- return true
- else
- centerText("Invalid key", 10)
- os.sleep(2)
- end
- else
- centerText("Recovery Key not found. Contact support.", 8)
- os.sleep(2)
- end
- return false
- end
- -- Function to start recovery key authentication
- local function authenticate()
- term.clear()
- drawBorderWithTitle("Doggy OS Secure Boot")
- if not verifyRecoveryKey() then
- os.reboot()
- end
- end
- -- Start authentication process
- authenticate()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement