Advertisement
DOGGYWOOF

Untitled

Feb 2nd, 2025 (edited)
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.28 KB | None | 0 0
  1. -- Doggy OS System Update Script with Enhanced UI
  2.  
  3. -- Function to draw a custom confirmation screen
  4. local function drawConfirmationScreen(title, message, yesCallback, noCallback)
  5. term.clear()
  6. term.setCursorPos(1, 1)
  7. term.setTextColor(colors.yellow)
  8. print(title)
  9. term.setTextColor(colors.white)
  10.  
  11. -- Draw the confirmation message
  12. print("\n" .. message)
  13. print("\n[YES] - Confirm [NO] - Cancel")
  14.  
  15. -- Wait for user input
  16. local response = read()
  17. if response:lower() == "yes" then
  18. yesCallback()
  19. else
  20. noCallback()
  21. end
  22. end
  23.  
  24. -- Function to draw the loading screen with progress bar
  25. local function drawLoadingScreen(progress, total, title, label)
  26. local barLength = 30
  27. local filledLength = math.floor((progress / total) * barLength)
  28. local emptyLength = barLength - filledLength
  29. local bar = "[" .. string.rep("=", filledLength) .. string.rep(" ", emptyLength) .. "]"
  30.  
  31. -- Clear the screen and display the loading screen
  32. term.clear()
  33. term.setCursorPos(1, 1)
  34. term.setTextColor(colors.yellow)
  35. print(title)
  36. term.setTextColor(colors.white)
  37. print(label)
  38. term.setCursorPos(1, 3)
  39. print("Progress:")
  40. term.setCursorPos(1, 4)
  41. term.clearLine()
  42. term.write(bar)
  43. term.setCursorPos(1, 5)
  44. term.clearLine()
  45. term.write(label .. " (" .. progress .. "/" .. total .. ")")
  46. end
  47.  
  48. -- Function to download a file from Pastebin
  49. local function downloadFromPastebin(pastebinURL, savePath)
  50. local response = http.get(pastebinURL)
  51. if response then
  52. local data = response.readAll()
  53. local file = fs.open(savePath, "w")
  54. file.write(data)
  55. file.close()
  56. return true
  57. else
  58. return false
  59. end
  60. end
  61.  
  62. -- Function to update the system
  63. local function updateSystem()
  64. local totalSteps = 4
  65. local currentStep = 0
  66. local title = "DOGGY OS SYSTEM UPDATE"
  67.  
  68. -- Show confirmation screen
  69. drawConfirmationScreen("System Update Confirmation",
  70. "This will delete the following files and update the system:\n/startup\n/reboot\nDo you wish to proceed?",
  71. function() -- If user clicks YES
  72. -- Start the update process
  73. drawLoadingScreen(currentStep, totalSteps, title, "Initializing Update...")
  74. sleep(1)
  75.  
  76. local filesToDelete = {"/startup", "/reboot"}
  77.  
  78. -- Delete files during the update process and show progress
  79. for _, file in ipairs(filesToDelete) do
  80. if fs.exists(file) then
  81. fs.delete(file)
  82. end
  83. currentStep = currentStep + 1
  84. drawLoadingScreen(currentStep, totalSteps, title, "Deleting Files...")
  85. sleep(1)
  86. end
  87.  
  88. -- Download the new startup and reboot files from Pastebin
  89. local pastebinURL = "https://pastebin.com/raw/9ahPi497"
  90. if downloadFromPastebin(pastebinURL, "/startup") then
  91. currentStep = currentStep + 1
  92. drawLoadingScreen(currentStep, totalSteps, title, "Downloading Startup File...")
  93. sleep(1)
  94. else
  95. print("Failed to download the new startup file.")
  96. return
  97. end
  98.  
  99. if downloadFromPastebin(pastebinURL, "/reboot") then
  100. currentStep = currentStep + 1
  101. drawLoadingScreen(currentStep, totalSteps, title, "Downloading Reboot File...")
  102. sleep(1)
  103. else
  104. print("Failed to download the new reboot file.")
  105. return
  106. end
  107.  
  108. -- Final step: Reboot the system
  109. drawLoadingScreen(totalSteps, totalSteps, title, "Update Complete! Rebooting...")
  110. sleep(2)
  111. os.reboot()
  112. end,
  113. function() -- If user clicks NO
  114. print("Update canceled.")
  115. end)
  116. end
  117.  
  118. -- Function to perform a factory reset
  119. local function factoryReset()
  120. drawConfirmationScreen("Factory Reset Warning",
  121. "This will delete all data and reset the system to factory settings.\nDo you wish to proceed?",
  122. function() -- If user clicks YES
  123. -- Perform the reset by deleting all files
  124. for _, file in ipairs(fs.list("/")) do
  125. if file ~= "startup" and file ~= "reboot" then
  126. fs.delete("/" .. file)
  127. end
  128. end
  129.  
  130. -- After reset, run the system update
  131. print("Factory reset complete. Running system update...")
  132. updateSystem()
  133. end,
  134. function() -- If user clicks NO
  135. print("Factory reset canceled.")
  136. end)
  137. end
  138.  
  139. -- Function to uninstall the system
  140. local function uninstallSystem()
  141. drawConfirmationScreen("System Uninstall Warning",
  142. "This will delete all data and uninstall the system completely.\nDo you wish to proceed?",
  143. function() -- If user clicks YES
  144. -- Perform the uninstall by deleting all files
  145. for _, file in ipairs(fs.list("/")) do
  146. fs.delete("/" .. file)
  147. end
  148.  
  149. -- Reboot after uninstallation
  150. print("System uninstalled. Rebooting...")
  151. os.reboot()
  152. end,
  153. function() -- If user clicks NO
  154. print("Uninstall canceled.")
  155. end)
  156. end
  157.  
  158. -- Function to display the main menu with options
  159. local function displayMainMenu()
  160. term.clear()
  161. term.setCursorPos(1, 1)
  162. term.setTextColor(colors.yellow)
  163. print("DOGGY OS RECOVERY AND FIRMWARE / SOFTWARE MANAGER")
  164. term.setTextColor(colors.white)
  165.  
  166. -- Display options for Factory Reset and System Uninstall
  167. print("\n1. System Update")
  168. print("2. Factory Reset")
  169. print("3. Uninstall System")
  170. print("\nChoose an option:")
  171.  
  172. local option = tonumber(read())
  173.  
  174. if option == 1 then
  175. updateSystem()
  176. elseif option == 2 then
  177. factoryReset()
  178. elseif option == 3 then
  179. uninstallSystem()
  180. else
  181. print("Invalid option. Please choose again.")
  182. displayMainMenu()
  183. end
  184. end
  185.  
  186. -- Run the main menu
  187. displayMainMenu()
  188.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement