Advertisement
DOGGYWOOF

Doggy OS advanced boot menu

Jan 27th, 2024 (edited)
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. -- Doggy OS Advanced Startup
  2.  
  3. -- Function to clear the screen and set cursor position
  4. local function clearScreen()
  5. term.clear()
  6. term.setCursorPos(1, 1)
  7. end
  8.  
  9. -- Function to display menu options
  10. local function displayMenu()
  11. clearScreen()
  12. print("Doggy OS Advanced Startup")
  13. print("1. System Reset")
  14. print("2. Power Options")
  15. print("3. Advanced Options")
  16. end
  17.  
  18. -- Function to handle system reset options
  19. local function systemReset()
  20. clearScreen()
  21. print("System Reset Options:")
  22. print("1. Reset this PC")
  23. print("2. Reset Pocket Computer")
  24. print("3. Reset Firmware")
  25.  
  26. local option = tonumber(read())
  27.  
  28. if option == 1 then
  29. -- Reset this PC
  30. print("Resetting this PC...")
  31. fs.delete("/disk/startup")
  32. for _, disk in pairs(peripheral.getNames()) do
  33. disk = peripheral.wrap(disk)
  34. disk.eject()
  35. end
  36. elseif option == 2 then
  37. -- Reset Pocket Computer
  38. print("Resetting Pocket Computer...")
  39. fs.delete("/disk2/disk")
  40. elseif option == 3 then
  41. -- Reset Firmware
  42. print("Resetting Firmware...")
  43. local success, err = pcall(fs.delete, "/disk/startup")
  44. if not success then
  45. print("Error: " .. err)
  46. sleep(3)
  47. end
  48. else
  49. print("Invalid option.")
  50. end
  51. end
  52.  
  53. -- Function to handle power options
  54. local function powerOptions()
  55. clearScreen()
  56. print("Power Options:")
  57. print("1. Reboot")
  58. print("2. Shutdown")
  59.  
  60. local option = tonumber(read())
  61.  
  62. if option == 1 then
  63. -- Reboot
  64. print("Rebooting...")
  65. os.reboot()
  66. elseif option == 2 then
  67. -- Shutdown
  68. print("Shutting down...")
  69. os.shutdown()
  70. else
  71. print("Invalid option.")
  72. end
  73. end
  74.  
  75. -- Function to handle advanced options
  76. local function advancedOptions()
  77. clearScreen()
  78. print("Advanced Options:")
  79. print("1. Command Shell - run /disk/bootloader/recovery-shell.lua")
  80. print("2. System Info - run /disk/bootloader/VA11-ILLA.lua")
  81.  
  82. local option = tonumber(read())
  83.  
  84. if option == 1 then
  85. -- Command Shell
  86. print("Running Command Shell...")
  87. local success, err = pcall(shell.run, "/disk/bootloader/recovery-shell.lua")
  88. if not success then
  89. print("Error: " .. err)
  90. sleep(3)
  91. end
  92. elseif option == 2 then
  93. -- System Info
  94. print("Running System Info...")
  95. local success, err = pcall(shell.run, "/disk/bootloader/VA11-ILLA.lua")
  96. if not success then
  97. print("Error: " .. err)
  98. sleep(3)
  99. end
  100. else
  101. print("Invalid option.")
  102. end
  103. end
  104.  
  105. -- Main program
  106. clearScreen()
  107. while true do
  108. displayMenu()
  109. local choice = tonumber(read())
  110.  
  111. if choice == 1 then
  112. systemReset()
  113. elseif choice == 2 then
  114. powerOptions()
  115. elseif choice == 3 then
  116. advancedOptions()
  117. else
  118. print("Invalid choice. Please try again.")
  119. end
  120. end
  121.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement