Advertisement
DOGGYWOOF

Untitled

Jul 9th, 2024 (edited)
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.52 KB | None | 0 0
  1. -- Paths
  2. local legacyConfigPath = "legacy.cfg"
  3. local recoveryPath = "/recovery"
  4. local dosRecoveryPath = "/DOS-RECOVERY"
  5. local errorFile = "/disk/boot/error"
  6. local startupFile = "/disk/boot/startup"
  7. local driveloadFile = "/disk/boot/driveload.exe"
  8. local startupLuaFile = "/disk/boot/startup.lua" -- New bootable file
  9.  
  10. -- Functions
  11. local function fileExists(path)
  12. return fs.exists(path)
  13. end
  14.  
  15. local function renameDirectory(oldPath, newPath)
  16. if fs.exists(oldPath) then
  17. fs.move(oldPath, newPath)
  18. end
  19. end
  20.  
  21. -- Function to display error screen
  22. local function displayErrorScreen()
  23. term.clear()
  24. term.setCursorPos(1, 1)
  25. print("BOOTLOADER ERROR: NO FILE FOUND")
  26. print("")
  27. print(" _________________")
  28. print(" | | ___________ |o|")
  29. print(" | | ___________ | |")
  30. print(" | | ___________ | |")
  31. print(" | | ___________ | |")
  32. print(" | |_____________| |")
  33. print(" | _______ |")
  34. print(" | | | ||")
  35. print(" | DD | | V|")
  36. print(" |____|_______|____|")
  37. print("")
  38. print("Press F1 to disable Legacy Boot")
  39. print("Press F10 to Attempt boot again")
  40. print("Press F8 to reboot system")
  41. print("Press F9 to search for Doggy OS Bootable drives")
  42. end
  43.  
  44. -- Main Logic
  45. if fileExists(legacyConfigPath) then
  46. -- Rename /recovery to /DOS-RECOVERY
  47. renameDirectory(recoveryPath, dosRecoveryPath)
  48.  
  49. -- Display ASCII art and message
  50. term.clear()
  51. term.setCursorPos(1, 1)
  52. print("Doggy OS Legacy Bootloader")
  53. print("")
  54. print(" _________________")
  55. print(" | | ___________ |o|")
  56. print(" | | ___________ | |")
  57. print(" | | ___________ | |")
  58. print(" | | ___________ | |")
  59. print(" | |_____________| |")
  60. print(" | _______ |")
  61. print(" | | | ||")
  62. print(" | DD | | V|")
  63. print(" |____|_______|____|")
  64. print("")
  65. print("Press F1 to disable legacy boot")
  66. print("Press F10 to run boot file")
  67.  
  68. -- Wait for key press
  69. local event, key
  70. repeat
  71. event, key = os.pullEvent("key")
  72. until key == keys.f1 or key == keys.f10
  73.  
  74. -- Handle key presses
  75. if key == keys.f1 then
  76. print("Disabling legacy boot...")
  77.  
  78. -- Rename /DOS-RECOVERY back to /recovery
  79. renameDirectory(dosRecoveryPath, recoveryPath)
  80.  
  81. -- Reboot the system
  82. os.reboot()
  83. elseif key == keys.f10 then
  84. print("Running boot file...")
  85.  
  86. -- Check and run startup.lua as a bootable file
  87. if fileExists(startupLuaFile) then
  88. shell.run(startupLuaFile)
  89. else
  90. -- Display error screen
  91. displayErrorScreen()
  92.  
  93. -- Wait for key press on error screen
  94. repeat
  95. event, key = os.pullEvent("key")
  96. until key == keys.f1 or key == keys.f8 or key == keys.f9 or key == keys.f10
  97.  
  98. -- Handle key presses on error screen
  99. if key == keys.f1 then
  100. print("Disabling legacy boot...")
  101.  
  102. -- Rename /DOS-RECOVERY back to /recovery
  103. renameDirectory(dosRecoveryPath, recoveryPath)
  104.  
  105. -- Reboot the system
  106. os.reboot()
  107. elseif key == keys.f8 then
  108. print("Rebooting system...")
  109.  
  110. -- Reboot the system
  111. os.reboot()
  112. elseif key == keys.f9 then
  113. print("Searching for Doggy OS Bootable drives...")
  114.  
  115. -- Perform search for bootable drives (add your logic here)
  116. -- For demonstration, let's assume we print a message
  117. print("No Doggy OS Bootable drives found.")
  118. elseif key == keys.f10 then
  119. print("Attempting boot again...")
  120.  
  121. -- Check and run other boot files
  122. if fileExists(errorFile) then
  123. shell.run(errorFile)
  124. end
  125.  
  126. if fileExists(startupFile) then
  127. shell.run(startupFile)
  128. end
  129.  
  130. if fileExists(driveloadFile) then
  131. shell.run(driveloadFile)
  132. end
  133. end
  134. end
  135. end
  136. else
  137. -- Display error screen if legacy.cfg does not exist
  138. displayErrorScreen()
  139.  
  140. -- Wait for key press on error screen
  141. repeat
  142. event, key = os.pullEvent("key")
  143. until key == keys.f1 or key == keys.f8 or key == keys.f9 or key == keys.f10
  144.  
  145. -- Handle key presses on error screen
  146. if key == keys.f1 then
  147. print("Disabling legacy boot...")
  148.  
  149. -- Reboot the system
  150. os.reboot()
  151. elseif key == keys.f8 then
  152. print("Rebooting system...")
  153.  
  154. -- Reboot the system
  155. os.reboot()
  156. elseif key == keys.f9 then
  157. print("Searching for Doggy OS Bootable drives...")
  158.  
  159. -- Perform search for bootable drives (add your logic here)
  160. -- For demonstration, let's assume we print a message
  161. print("No Doggy OS Bootable drives found.")
  162. elseif key == keys.f10 then
  163. print("Attempting boot again...")
  164.  
  165. -- Check and run other boot files
  166. if fileExists(errorFile) then
  167. shell.run(errorFile)
  168. end
  169.  
  170. if fileExists(startupFile) then
  171. shell.run(startupFile)
  172. end
  173.  
  174. if fileExists(driveloadFile) then
  175. shell.run(driveloadFile)
  176. end
  177. end
  178. end
  179.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement