Advertisement
DOGGYWOOF

Untitled

Oct 19th, 2024 (edited)
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. -- secureBootCheck.lua
  2.  
  3. -- Function to check if .settings file exists and contains shell.allow_disk_startup
  4. local function isSecureBootConfigured()
  5. local settingsPath = "/.settings"
  6. if fs.exists(settingsPath) then
  7. local file = fs.open(settingsPath, "r")
  8. if file then
  9. local contents = file.readAll()
  10. file.close()
  11. -- Check if .settings contains shell.allow_disk_startup
  12. if not string.find(contents, '["%s-]shell%.allow_disk_startup["%s-]') then
  13. return false -- shell.allow_disk_startup not found
  14. end
  15. end
  16. else
  17. -- .settings file doesn't exist
  18. return false -- Secure boot configuration file is missing
  19. end
  20. return true -- Secure boot is properly configured
  21. end
  22.  
  23. -- Function to display the fullscreen error
  24. local function showErrorScreen()
  25. term.clear()
  26. term.setCursorPos(1, 1)
  27.  
  28. -- ASCII art with red dog and X eyes
  29. local asciiArt = [[
  30. |\_/|
  31. | X X Doggy OS Security!
  32. | <> _
  33. | _/\------____ ((| |))
  34. | `--' |
  35. ____|_ ___| |___.'
  36. /_/_____/____/_______|
  37. ]]
  38.  
  39. -- Error and instruction messages
  40. local errorMessage = "Script blocked due to security policy."
  41. local instructionMessage = "Press F1 to cancel."
  42.  
  43. -- Calculate positions for centering the ASCII art
  44. local width, height = term.getSize()
  45. local artLines = {}
  46. for line in asciiArt:gmatch("[^\r\n]+") do
  47. table.insert(artLines, line)
  48. end
  49.  
  50. local startY = math.floor((height - #artLines - 4) / 2) -- Adjust for extra lines
  51. local startX = math.floor((width - #artLines[1]) / 2)
  52.  
  53. -- Display ASCII art centered with red color
  54. term.setTextColor(colors.red) -- Set text color to red
  55. for i, line in ipairs(artLines) do
  56. term.setCursorPos(startX, startY + i)
  57. term.write(line)
  58. end
  59. term.setTextColor(colors.white) -- Reset text color to white
  60.  
  61. -- Display the error message, slightly raised
  62. local messageX = math.floor((width - #errorMessage) / 2)
  63. term.setCursorPos(messageX, startY + #artLines + 2) -- Adjusted position
  64. term.write(errorMessage)
  65.  
  66. -- Display the instruction message at the bottom, centered
  67. local instructionX = math.floor((width - #instructionMessage) / 2)
  68. term.setCursorPos(instructionX, height - 1) -- Position at the bottom
  69. term.write(instructionMessage)
  70.  
  71. -- Prevent further execution until F1 is pressed
  72. while true do
  73. local event, key = os.pullEvent("key")
  74. if key == keys.f1 then
  75. term.setCursorPos(1, 1) -- Set cursor position before exiting
  76. term.clear() -- Clear the screen before exiting the loop
  77. break -- Exit the loop when F1 is pressed
  78. end
  79. end
  80. end
  81.  
  82. -- Run the secure boot check and show error if it fails
  83. if not isSecureBootConfigured() then
  84. showErrorScreen()
  85. end
  86.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement