Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- secureBootCheck.lua
- -- Function to check if .settings file exists and contains shell.allow_disk_startup
- local function isSecureBootConfigured()
- local settingsPath = "/.settings"
- if fs.exists(settingsPath) then
- local file = fs.open(settingsPath, "r")
- if file then
- local contents = file.readAll()
- file.close()
- -- Check if .settings contains shell.allow_disk_startup
- if not string.find(contents, '["%s-]shell%.allow_disk_startup["%s-]') then
- return false -- shell.allow_disk_startup not found
- end
- end
- else
- -- .settings file doesn't exist
- return false -- Secure boot configuration file is missing
- end
- return true -- Secure boot is properly configured
- end
- -- Function to display the fullscreen error
- local function showErrorScreen()
- term.clear()
- term.setCursorPos(1, 1)
- -- ASCII art with red dog and X eyes
- local asciiArt = [[
- |\_/|
- | X X Doggy OS Security!
- | <> _
- | _/\------____ ((| |))
- | `--' |
- ____|_ ___| |___.'
- /_/_____/____/_______|
- ]]
- -- Error and instruction messages
- local errorMessage = "Script blocked due to security policy."
- local instructionMessage = "Press F1 to cancel."
- -- Calculate positions for centering the ASCII art
- local width, height = term.getSize()
- local artLines = {}
- for line in asciiArt:gmatch("[^\r\n]+") do
- table.insert(artLines, line)
- end
- local startY = math.floor((height - #artLines - 4) / 2) -- Adjust for extra lines
- local startX = math.floor((width - #artLines[1]) / 2)
- -- Display ASCII art centered with red color
- term.setTextColor(colors.red) -- Set text color to red
- for i, line in ipairs(artLines) do
- term.setCursorPos(startX, startY + i)
- term.write(line)
- end
- term.setTextColor(colors.white) -- Reset text color to white
- -- Display the error message, slightly raised
- local messageX = math.floor((width - #errorMessage) / 2)
- term.setCursorPos(messageX, startY + #artLines + 2) -- Adjusted position
- term.write(errorMessage)
- -- Display the instruction message at the bottom, centered
- local instructionX = math.floor((width - #instructionMessage) / 2)
- term.setCursorPos(instructionX, height - 1) -- Position at the bottom
- term.write(instructionMessage)
- -- Prevent further execution until F1 is pressed
- while true do
- local event, key = os.pullEvent("key")
- if key == keys.f1 then
- term.setCursorPos(1, 1) -- Set cursor position before exiting
- term.clear() -- Clear the screen before exiting the loop
- break -- Exit the loop when F1 is pressed
- end
- end
- end
- -- Run the secure boot check and show error if it fails
- if not isSecureBootConfigured() then
- showErrorScreen()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement