Advertisement
DOGGYWOOF

FW

Jul 7th, 2024 (edited)
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.81 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) - 1)
  42. centerText("Press Enter for boot options", math.floor(h / 2) + 1)
  43. end
  44.  
  45. -- Function to load the boot animation
  46. local function loadBootAnimation()
  47. if fs.exists("/disk/boot/boot-animation") then
  48. shell.run("/disk/boot/boot-animation")
  49. else
  50. print("Boot animation not found!")
  51. end
  52. end
  53.  
  54. -- Function to load the boot options
  55. local function loadBootOptions()
  56. if fs.exists("/disk/boot/boot-options") then
  57. shell.run("/disk/boot/boot-options")
  58. else
  59. print("Boot options not found!")
  60. end
  61. end
  62.  
  63. -- Function to check the password
  64. local function checkPassword()
  65. if fs.exists("/FW-Security/BIOS/Boot/poweron.pass") then
  66. local file = fs.open("/FW-Security/BIOS/Boot/poweron.pass", "r")
  67. local correctPassword = file.readAll()
  68. file.close()
  69.  
  70. while true do
  71. drawBorder()
  72. local _, h = term.getSize()
  73. centerText("Embedded Security Password", math.floor(h / 2) - 2)
  74. centerText("Enter Password:", math.floor(h / 2))
  75. term.setCursorPos(math.floor(term.getSize() / 2), math.floor(h / 2) + 1)
  76. local password = read("*") -- Read the password, hiding input
  77.  
  78. if password == correctPassword then
  79. return true
  80. else
  81. local timeoutFile = "/FW-Security/BIOS/Boot/TIMEOUT"
  82. local f = fs.open(timeoutFile, "w")
  83. f.close()
  84. return false
  85. end
  86. end
  87. end
  88. return true
  89. end
  90.  
  91. -- Function to handle timeout
  92. local function handleTimeout()
  93. local timeoutFile = "/FW-Security/BIOS/Boot/TIMEOUT"
  94. if fs.exists(timeoutFile) then
  95. local timeout = 30
  96. while timeout > 0 do
  97. drawBorder()
  98. local _, h = term.getSize()
  99. centerText("Incorrect password.", math.floor(h / 2) - 1)
  100. centerText("System locked for " .. timeout .. " seconds.", math.floor(h / 2))
  101. sleep(1)
  102. timeout = timeout - 1
  103. end
  104. fs.delete(timeoutFile)
  105. os.reboot()
  106. end
  107. end
  108.  
  109. -- Main function to handle UEFI message and timeout
  110. local function main()
  111. handleTimeout()
  112.  
  113. if not checkPassword() then
  114. handleTimeout()
  115. return
  116. end
  117.  
  118. showUEFIMessage()
  119. local timer = os.startTimer(2) -- Set a timer for 2 seconds
  120.  
  121. while true do
  122. local event, param = os.pullEvent()
  123. if event == "key" and param == keys.enter then
  124. -- Load boot options if Enter is pressed
  125. loadBootOptions()
  126. return
  127. elseif event == "timer" and param == timer then
  128. -- Timer expired, load boot animation
  129. loadBootAnimation()
  130. return
  131. end
  132. end
  133. end
  134.  
  135. -- Start the main function
  136. main()
  137.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement