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
- local asciiArt = [[
- |\_/|
- | @ @ Doggy OS Security!
- | <> _
- | _/\------____ ((| |))
- | `--' |
- ____|_ ___| |___.'
- /_/_____/____/_______|
- ]]
- -- Shorter error message
- local errorMessage = "Security error. This function has failed"
- -- 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 - 2) / 2)
- local startX = math.floor((width - #artLines[1]) / 2)
- -- Display ASCII art centered
- for i, line in ipairs(artLines) do
- term.setCursorPos(startX, startY + i)
- term.write(line)
- end
- -- Display the shorter error message below the ASCII art, centered
- local messageX = math.floor((width - #errorMessage) / 2)
- term.setCursorPos(messageX, startY + #artLines + 2)
- term.write(errorMessage)
- -- Prevent further execution
- while true do
- os.pullEvent("key")
- 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