Advertisement
DOGGYWOOF

Untitled

Mar 21st, 2024 (edited)
7
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.29 KB | None | 0 0
  1. local function clearScreen()
  2. term.clear()
  3. term.setCursorPos(1, 1)
  4. end
  5.  
  6. local function showError(errorMessage)
  7. clearScreen()
  8. print("Error: " .. errorMessage)
  9. sleep(2)
  10. end
  11.  
  12. local function showMainMenu()
  13. clearScreen()
  14. print("Main Menu:")
  15. print("1. Recovery")
  16. print("2. Applications")
  17. print("3. Device Info")
  18. print("4. Exit")
  19. end
  20.  
  21. local function showRecoveryMenu()
  22. clearScreen()
  23. print("Recovery Menu:")
  24. print("1. Reset PIN")
  25. print("2. Wipe Device")
  26. print("3. Backup OS")
  27. print("4. Restore OS")
  28. print("5. Back to Main Menu")
  29. end
  30.  
  31. local function showAppsMenu()
  32. clearScreen()
  33. print("Applications Menu:")
  34. print("1. Sideload Apps")
  35. print("2. Download Apps from Connected Device")
  36. print("3. Reset Apps")
  37. print("4. Back to Main Menu")
  38. end
  39.  
  40. local function deviceInfo()
  41. clearScreen()
  42. print("Device Info:")
  43. local label = os.getComputerLabel() or "Unnamed Device"
  44. print("Label: " .. label)
  45. print("Doggy OS Version: 1.0") -- Update with actual version
  46. local va11illaVersion = "Unknown"
  47. local va11illaFile = fs.open("/disk2/disk/bootloader/VA11-ILLA.lua", "r")
  48. if va11illaFile then
  49. local va11illaContent = va11illaFile.readAll()
  50. va11illaFile.close()
  51. va11illaVersion = string.match(va11illaContent, 'version%s*=%s*"([^"]+)"') or "Unknown"
  52. end
  53. print("VA11-ILLA Version: " .. va11illaVersion)
  54. print("Security: High") -- Example security level
  55. print("Press Enter to return to the Main Menu")
  56. read() -- Wait for user input before returning to main menu
  57. end
  58.  
  59. local function resetPIN()
  60. clearScreen()
  61. print("Reset PIN:")
  62. print("Enter new PIN:")
  63. local newPIN = read("*n")
  64. print("Confirm new PIN:")
  65. local confirmPIN = read("*n")
  66.  
  67. if newPIN == confirmPIN then
  68. local configFile = fs.open("/disk/PIN.config", "w")
  69. configFile.write(tostring(newPIN))
  70. configFile.close()
  71. print("PIN reset successfully.")
  72. else
  73. showError("PINs do not match. Operation aborted.")
  74. end
  75. sleep(2)
  76. end
  77.  
  78. local function wipeDevice()
  79. clearScreen()
  80. print("Wipe Device:")
  81. fs.delete("/disk2/disk/")
  82. fs.delete("/disk2/startup")
  83. fs.delete("/disk2/no-os")
  84. print("Device wiped successfully.")
  85. sleep(2)
  86. end
  87.  
  88. local function backupOS()
  89. clearScreen()
  90. print("Backup OS:")
  91. fs.copy("/disk2/disk/", "/" .. os.getComputerLabel() .. "-Backup/")
  92. print("OS backed up successfully.")
  93. sleep(2)
  94. end
  95.  
  96. local function restoreOS()
  97. clearScreen()
  98. print("Restore OS:")
  99. fs.copy("/" .. os.getComputerLabel() .. "-Backup/", "/disk2/disk/")
  100. fs.move("/disk2/startup", "/")
  101. fs.move("/disk2/no-os", "/")
  102. print("OS restored successfully.")
  103. sleep(2)
  104. end
  105.  
  106. local function sideloadApps()
  107. clearScreen()
  108. print("Sideload Apps:")
  109. print("Enter app name or directory to sideload:")
  110. local appPath = read()
  111. local success, error = pcall(function()
  112. fs.copy(appPath, "/disk2/disk/packages/")
  113. print("App sideloaded successfully.")
  114. end)
  115. if not success then
  116. showError(error)
  117. end
  118. sleep(2)
  119. end
  120.  
  121. local function downloadApps()
  122. clearScreen()
  123. print("Download Apps from Connected Device:")
  124. print("Enter app name or directory to download:")
  125. local appPath = read()
  126. local success, error = pcall(function()
  127. fs.copy(appPath, "/disk/")
  128. print("App downloaded successfully.")
  129. end)
  130. if not success then
  131. showError(error)
  132. end
  133. sleep(2)
  134. end
  135.  
  136. local function resetApps()
  137. clearScreen()
  138. print("Reset Apps:")
  139. local files = fs.list("/disk2/disk/packages")
  140. for _, file in ipairs(files) do
  141. if file ~= "Package-installer" then
  142. fs.delete("/disk2/disk/packages/" .. file)
  143. end
  144. end
  145. print("Apps reset successfully.")
  146. sleep(2)
  147. end
  148.  
  149. while true do
  150. showMainMenu()
  151. local choice = tonumber(read())
  152. if choice == 1 then
  153. while true do
  154. showRecoveryMenu()
  155. local recoveryChoice = tonumber(read())
  156. if recoveryChoice == 1 then
  157. resetPIN()
  158. elseif recoveryChoice == 2 then
  159. wipeDevice()
  160. elseif recoveryChoice == 3 then
  161. backupOS()
  162. elseif recoveryChoice == 4 then
  163. restoreOS()
  164. elseif recoveryChoice == 5 then
  165. break
  166. else
  167. showError("Invalid choice.")
  168. end
  169. end
  170. elseif choice == 2 then
  171. while true do
  172. showAppsMenu()
  173. local appsChoice = tonumber(read())
  174. if appsChoice == 1 then
  175. sideloadApps()
  176. elseif appsChoice == 2 then
  177. downloadApps()
  178. elseif appsChoice == 3 then
  179. resetApps()
  180. elseif appsChoice == 4 then
  181. break
  182. else
  183. showError("Invalid choice.")
  184. end
  185. end
  186. elseif choice == 3 then
  187. deviceInfo()
  188. elseif choice == 4 then
  189. clearScreen()
  190. print("Exiting...")
  191. sleep(1)
  192. break
  193. else
  194. showError("Invalid choice.")
  195. end
  196. end
  197.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement