Advertisement
DOGGYWOOF

Untitled

Jul 7th, 2024 (edited)
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.27 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 show the Doggy OS Authentication screen
  64. local function showAuthScreen()
  65. drawBorder()
  66. local _, h = term.getSize()
  67. centerText("Doggy OS Authentication", math.floor(h / 2) - 1)
  68. centerText("F10 has been pressed", math.floor(h / 2) + 1)
  69. end
  70.  
  71. -- Function to check the password
  72. local function checkPassword()
  73. local passwordFile = "/disk/security/poweron.pass"
  74. if fs.exists(passwordFile) then
  75. local file = fs.open(passwordFile, "r")
  76. local correctPassword = file.readAll()
  77. file.close()
  78.  
  79. while true do
  80. drawBorder()
  81. local _, h = term.getSize()
  82. centerText("Embedded Security Password", math.floor(h / 2) - 2)
  83. centerText("Enter Password:", math.floor(h / 2))
  84. term.setCursorPos(math.floor((term.getSize() / 2)), math.floor(h / 2) + 1)
  85. local password = read("*") -- Read the password, hiding input
  86.  
  87. if password == correctPassword then
  88. return true
  89. else
  90. local timeoutFile = "/FW-Security/BIOS/Boot/TIMEOUT"
  91. local f = fs.open(timeoutFile, "w")
  92. f.close()
  93. return false
  94. end
  95. end
  96. end
  97. return true
  98. end
  99.  
  100. -- Function to handle timeout
  101. local function handleTimeout()
  102. local timeoutFile = "/FW-Security/BIOS/Boot/TIMEOUT"
  103. if fs.exists(timeoutFile) then
  104. local timeout = 30
  105. while timeout > 0 do
  106. drawBorder()
  107. local _, h = term.getSize()
  108. centerText("Incorrect password.", math.floor(h / 2) - 1)
  109. centerText("System locked for " .. timeout .. " seconds.", math.floor(h / 2))
  110. sleep(1)
  111. timeout = timeout - 1
  112. end
  113. fs.delete(timeoutFile)
  114. os.reboot()
  115. end
  116. end
  117.  
  118. -- Main function to handle UEFI message and timeout
  119. local function main()
  120. handleTimeout()
  121.  
  122. if not checkPassword() then
  123. handleTimeout()
  124. return
  125. end
  126.  
  127. showUEFIMessage()
  128. local timer = os.startTimer(2) -- Set a timer for 2 seconds
  129.  
  130. while true do
  131. local event, param1, param2, param3 = os.pullEvent()
  132. if event == "key" and param1 == keys.enter then
  133. -- Load boot options if Enter is pressed
  134. loadBootOptions()
  135. return
  136. elseif event == "key" and param1 == keys.f10 then
  137. -- Show Authentication screen if F10 is pressed
  138. showAuthScreen()
  139. return
  140. elseif event == "timer" and param1 == timer then
  141. -- Timer expired, load boot animation
  142. loadBootAnimation()
  143. return
  144. end
  145. end
  146. end
  147.  
  148. -- Start the main function
  149. main()
  150.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement