Advertisement
DOGGYWOOF

Untitled

Feb 7th, 2025 (edited)
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.52 KB | None | 0 0
  1. -- Doggy OS Systems
  2. -- DogRE 13.0 (N3K0 V13 CFG)
  3.  
  4. local function clearScreen(message)
  5. term.clear()
  6. term.setCursorPos(1, 1)
  7. if message then
  8. print(message)
  9. end
  10. end
  11.  
  12. local function waitForDisk(diskPath, message)
  13. clearScreen(message)
  14. while not fs.exists(diskPath) do
  15. sleep(1)
  16. end
  17. end
  18.  
  19. local function promptForEnter(message)
  20. print(message .. " Press Enter to continue...")
  21. io.read() -- Wait for user to press Enter
  22. end
  23.  
  24. local function askToOverride(filePath)
  25. clearScreen("File " .. filePath .. " already exists.\nDo you want to override it?\n1. Yes\n2. No (Skip)")
  26. local choice = tonumber(io.read())
  27. if choice == 1 then
  28. return true -- User wants to override
  29. else
  30. return false -- User wants to skip
  31. end
  32. end
  33.  
  34. -- Enhanced error display
  35. local function displayError(errorMsg, errorCode)
  36. clearScreen("===== DOGGY OS SYSTEM RECOVERY ERROR =====")
  37. print("Error Message: " .. errorMsg)
  38.  
  39. print("Error Code: DOSx7002")
  40.  
  41. print("\nPossible Causes:")
  42. print("1. Missing or corrupted files.")
  43. print("2. Disk access errors.")
  44. print("3. Unexpected system behavior.")
  45. print("\nSuggested Actions:")
  46. print("1. Check disk connections and try again.")
  47. print("2. Run a full system recovery.")
  48. print("3. Contact support if the issue persists.\n")
  49. promptForEnter("Press Enter to Reboot system and return to normal system environment")
  50. end
  51.  
  52. local function performAction(action, successMessage, failureMessage)
  53. clearScreen()
  54. local success, err = pcall(action)
  55. if success then
  56. print(successMessage)
  57. else
  58. displayError(failureMessage or "An unexpected error occurred.", err)
  59. end
  60. sleep(2)
  61. end
  62.  
  63. -- Define showLoadingScreen function
  64. local function showLoadingScreen(message, totalSteps)
  65. local barLength = 30 -- Length of the loading bar
  66. clearScreen(message)
  67. for step = 1, totalSteps do
  68. term.setCursorPos(1, 3)
  69. write("[")
  70. for i = 1, barLength do
  71. if i <= math.floor((step / totalSteps) * barLength) then
  72. write("=") -- Progress part of the bar
  73. else
  74. write(" ") -- Empty part of the bar
  75. end
  76. end
  77. write("] " .. math.floor((step / totalSteps) * 100) .. "%")
  78. sleep(0.3) -- Slow down the animation for better visual effect
  79. end
  80. end
  81.  
  82. -- Verify System Mode (Checks for issues but makes no fixes)
  83. local function verifySystem()
  84. clearScreen("Verifying system files...\nPlease wait...")
  85.  
  86. local function checkFileIntegrity(sourceDir, targetDir, excludeDir)
  87. local files = fs.list(sourceDir)
  88. for _, file in ipairs(files) do
  89. local sourcePath = fs.combine(sourceDir, file)
  90. local targetPath = fs.combine(targetDir, file)
  91.  
  92. if fs.isDir(sourcePath) then
  93. if not sourcePath:match(excludeDir) then
  94. checkFileIntegrity(sourcePath, targetPath, excludeDir)
  95. end
  96. else
  97. if not fs.exists(targetPath) then
  98. print("Missing file: " .. targetPath)
  99. end
  100. end
  101. end
  102. end
  103.  
  104. checkFileIntegrity("/recovery", "/disk", "/disk/users")
  105.  
  106. promptForEnter("Verification complete. No changes were made.")
  107. end
  108.  
  109. local function fullSystemRecovery()
  110. performAction(
  111. function()
  112. local function checkAndCopyMissingFiles()
  113. local function copyFileIfMissing(sourcePath, targetPath)
  114. if not fs.exists(targetPath) then
  115. print("Copying missing file: " .. sourcePath)
  116. fs.copy(sourcePath, targetPath)
  117. else
  118. print("File already exists, skipping: " .. targetPath)
  119. end
  120. end
  121.  
  122. local function checkDirectory(sourceDir, targetDir, excludeDir)
  123. local files = fs.list(sourceDir)
  124. for _, file in ipairs(files) do
  125. local sourcePath = fs.combine(sourceDir, file)
  126. local targetPath = fs.combine(targetDir, file)
  127.  
  128. if fs.isDir(sourcePath) then
  129. if not sourcePath:match(excludeDir) then
  130. checkDirectory(sourcePath, targetPath, excludeDir)
  131. end
  132. else
  133. copyFileIfMissing(sourcePath, targetPath)
  134. end
  135. end
  136. end
  137.  
  138. checkDirectory("/recovery", "/disk", "/disk/users")
  139. end
  140.  
  141. checkAndCopyMissingFiles()
  142. end,
  143. "Full System Recovery completed."
  144. )
  145.  
  146. showLoadingScreen("Doggy OS System Recovery...", 50)
  147.  
  148. clearScreen("Recovery process completed.\nThe system is now restored.")
  149. promptForEnter("Press Enter to exit")
  150. end
  151.  
  152. local function wipeDataAndResetFactoryDefaults()
  153. performAction(
  154. function()
  155. clearScreen("Wiping data and resetting to factory defaults...\nThis may take a while...")
  156.  
  157. if fs.exists("/disk") then
  158. local function deleteDirContent(path, exclude)
  159. local files = fs.list(path)
  160. for _, file in ipairs(files) do
  161. local fullPath = fs.combine(path, file)
  162.  
  163. if fs.isDir(fullPath) then
  164. if exclude and fullPath:sub(1, #exclude) == exclude then
  165. print("Skipping: " .. fullPath)
  166. else
  167. deleteDirContent(fullPath, exclude)
  168. end
  169. else
  170. fs.delete(fullPath)
  171. end
  172. end
  173. end
  174. deleteDirContent("/disk", "/disk/users")
  175. end
  176.  
  177. if fs.exists("/.doggyfactorydefaults") then
  178. local function copyDirContent(source, destination)
  179. local files = fs.list(source)
  180. for _, file in ipairs(files) do
  181. local sourcePath = fs.combine(source, file)
  182. local destinationPath = fs.combine(destination, file)
  183.  
  184. print("Copying: " .. sourcePath .. " -> " .. destinationPath)
  185.  
  186. if fs.isDir(sourcePath) then
  187. if not fs.exists(destinationPath) then
  188. fs.makeDir(destinationPath)
  189. end
  190. copyDirContent(sourcePath, destinationPath)
  191. else
  192. fs.copy(sourcePath, destinationPath)
  193. end
  194. end
  195. end
  196. copyDirContent("/.doggyfactorydefaults", "/disk")
  197. else
  198. error("Error: /.doggyfactorydefaults not found.")
  199. end
  200.  
  201. showLoadingScreen("Doggy OS Factory Reset...", 50)
  202.  
  203. shell.run("/disk/setup")
  204. end,
  205. "Wipe data and reset to factory defaults completed."
  206. )
  207. end
  208.  
  209. local function recoveryMenu()
  210. while true do
  211. clearScreen("===== Recovery Options =====\n1. Full System Recovery\n2. Wipe Data / Reset to Factory Defaults\n3. Verify System Integrity\n4. Exit")
  212. local choice = tonumber(io.read())
  213. if choice == 1 then
  214. fullSystemRecovery()
  215. elseif choice == 2 then
  216. wipeDataAndResetFactoryDefaults()
  217. elseif choice == 3 then
  218. verifySystem()
  219. elseif choice == 4 then
  220. break
  221. else
  222. clearScreen("Invalid choice. Please try again.")
  223. sleep(2)
  224. end
  225. end
  226. end
  227.  
  228. local function powerMenu()
  229. clearScreen("===== Power Options =====\n1. Reboot system\n2. Shutdown system")
  230. local choice = tonumber(io.read())
  231. if choice == 1 then
  232. os.reboot()
  233. elseif choice == 2 then
  234. os.shutdown()
  235. else
  236. clearScreen("Invalid choice. Please try again.")
  237. sleep(2)
  238. end
  239. end
  240.  
  241. local function mainMenu()
  242. while true do
  243. clearScreen("===== Doggy OS DEV Recovery GUI =====\n1. Recovery Options\n2. Power Options\n3. Exit")
  244. local choice = tonumber(io.read())
  245. if choice == 1 then
  246. recoveryMenu()
  247. elseif choice == 2 then
  248. powerMenu()
  249. else
  250. break
  251. end
  252. end
  253. end
  254.  
  255. if fs.exists("/disk/config/dogRE/disableRE.cfg") then
  256. clearScreen("===== DOGGY OS SYSTEM RECOVERY ERROR =====")
  257. print("Error Message: " .. "Recovery Environment Disabled")
  258.  
  259. print("Error Code: DOSx7000")
  260.  
  261. print("\nPossible Causes:")
  262. print("1. Recovery Environment has been disabled by your system administrator")
  263. print("2. Malware or unwanted software disabled DogRE")
  264. print("3. System config errors or corruption")
  265. print("\nSuggested Actions:")
  266. print("1. Reboot the computer and re-enable DogRE")
  267. print("2. Reinstall Doggy OS or rebuild the recovery partition")
  268. print("3. Contact support if the issue persists.\n")
  269. promptForEnter("Press Enter to Reboot system and return to normal system environment")
  270.  
  271.  
  272. else
  273. if fs.exists ("/recovery")
  274. then
  275. mainMenu()
  276.  
  277. else
  278. displayError("Recovery Environment Failed to load", "DOSx7002")
  279. end
  280. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement