Advertisement
DOGGYWOOF

Untitled

Dec 6th, 2024 (edited)
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.12 KB | None | 0 0
  1. -- Doggy OS UEFI
  2.  
  3. -- Function to draw a border
  4. local function drawBorder()
  5. term.clear()
  6. local w, h = term.getSize()
  7. for y = 1, h do
  8. term.setCursorPos(1, y)
  9. term.write("|")
  10. term.setCursorPos(w, y)
  11. term.write("|")
  12. end
  13. for x = 1, w do
  14. term.setCursorPos(x, 1)
  15. term.write("-")
  16. term.setCursorPos(x, h)
  17. term.write("-")
  18. end
  19. term.setCursorPos(1, 1)
  20. term.write("+")
  21. term.setCursorPos(w, 1)
  22. term.write("+")
  23. term.setCursorPos(1, h)
  24. term.write("+")
  25. term.setCursorPos(w, h)
  26. term.write("+")
  27. end
  28.  
  29. -- Function to center text on the screen
  30. local function centerText(text, y)
  31. local w, _ = term.getSize()
  32. local x = math.floor((w - #text) / 2) + 1
  33. term.setCursorPos(x, y)
  34. term.write(text)
  35. end
  36.  
  37. -- Function to show the UEFI message
  38. local function showUEFIMessage()
  39. drawBorder()
  40. local _, h = term.getSize()
  41. centerText("Doggy OS UEFI", math.floor(h / 2))
  42. end
  43.  
  44. -- Function to display an error screen
  45. local function showErrorScreen(message)
  46. term.setBackgroundColor(colors.red)
  47. term.setTextColor(colors.white)
  48. term.clear()
  49. drawBorder()
  50. local _, h = term.getSize()
  51. centerText("Doggy OS Internal Bootloader Error:", math.floor(h / 2) - 2)
  52. centerText(message, math.floor(h / 2))
  53. centerText("Press any key to restart...", math.floor(h / 2) + 2)
  54. os.pullEvent("key") -- Wait for a key press
  55. os.reboot() -- Reboot the system
  56. end
  57.  
  58. -- Function to load the boot animation
  59. local function loadBootAnimation()
  60. if fs.exists("/disk/boot/boot-animation") then
  61. shell.run("/disk/boot/boot-animation")
  62. else
  63. print("Boot animation not found!")
  64. end
  65. end
  66.  
  67. -- Function to check the password
  68. local function checkPassword()
  69. if fs.exists("/FW-Security/BIOS/Boot/poweron.pass") then
  70. local file = fs.open("/FW-Security/BIOS/Boot/poweron.pass", "r")
  71. local correctPassword = file.readAll()
  72. file.close()
  73.  
  74. while true do
  75. drawBorder()
  76. local _, h = term.getSize()
  77. centerText("Doggy OS Boot Authentication", math.floor(h / 2) - 2)
  78. centerText("Enter Password:", math.floor(h / 2))
  79. term.setCursorPos(math.floor(term.getSize() / 2), math.floor(h / 2) + 1)
  80. local password = read("*") -- Read the password, hiding input
  81.  
  82. if password == correctPassword then
  83. return true
  84. else
  85. local timeoutFile = "/FW-Security/BIOS/Boot/TIMEOUT"
  86. local f = fs.open(timeoutFile, "w")
  87. f.close()
  88. return false
  89. end
  90. end
  91. end
  92. return true
  93. end
  94.  
  95. -- Function to handle timeout
  96. local function handleTimeout()
  97. local timeoutFile = "/FW-Security/BIOS/Boot/TIMEOUT"
  98. if fs.exists(timeoutFile) then
  99. local timeout = 30
  100. while timeout > 0 do
  101. drawBorder()
  102. local _, h = term.getSize()
  103. centerText("Incorrect password.", math.floor(h / 2) - 1)
  104. centerText("System locked for " .. timeout .. " seconds.", math.floor(h / 2))
  105. sleep(1)
  106. timeout = timeout - 1
  107. end
  108. fs.delete(timeoutFile)
  109. os.reboot()
  110. end
  111. end
  112.  
  113. -- Main function to handle UEFI message, shutdown screen, and timeout
  114. local function main()
  115. -- Check if multishell is supported
  116. if not multishell then
  117. showErrorScreen("Multishell is not supported on this system.")
  118. return
  119. end
  120.  
  121. handleTimeout()
  122.  
  123. if not checkPassword() then
  124. handleTimeout()
  125. return
  126. end
  127.  
  128. -- Show UEFI message and wait for 2 seconds
  129. showUEFIMessage()
  130. local timer = os.startTimer(2) -- Set a timer for 2 seconds
  131.  
  132. while true do
  133. local event, param = os.pullEvent()
  134. if event == "timer" and param == timer then
  135. -- After 2 seconds, execute the shutdown script
  136. shell.run("/disk/DOG_FS") -- Run the shutdown script
  137. return
  138. end
  139. end
  140. end
  141.  
  142. -- Start the main function
  143. main()
  144.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement