Advertisement
DOGGYWOOF

Open OS Recovery enviroment

Jul 20th, 2024 (edited)
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. local component = require("component")
  2. local os = require("os")
  3.  
  4. local function diskInserted()
  5. local drives = component.list("drive")
  6. for address in drives do
  7. local drive = component.proxy(address)
  8. if drive.isDiskPresent() then
  9. return address
  10. end
  11. end
  12. return nil
  13. end
  14.  
  15. local function bootFromDisk(driveAddress)
  16. local drive = component.proxy(driveAddress)
  17. if drive.isDiskPresent() then
  18. local mountPath = "/mnt/" .. driveAddress:sub(1, 3)
  19. local bootFilePath = mountPath .. "/boot.lua"
  20.  
  21. local file = io.open(bootFilePath, "r")
  22. if file then
  23. local code = file:read("*a")
  24. file:close()
  25. local func, loadError = load(code)
  26. if func then
  27. func() -- Execute the boot script
  28. end
  29. end
  30. end
  31. end
  32.  
  33. -- Main BIOS loop
  34. local status = "No disk detected. Please insert the disk."
  35.  
  36. while true do
  37. local driveAddress = diskInserted()
  38. if driveAddress then
  39. status = "Disk detected in drive " .. driveAddress .. ". Attempting to boot from the disk..."
  40. bootFromDisk(driveAddress)
  41. break
  42. else
  43. os.sleep(2) -- Check every 2 seconds
  44. end
  45. end
  46.  
  47. -- End of BIOS script
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement