Advertisement
DOGGYWOOF

delete after

Feb 19th, 2024 (edited)
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.87 KB | None | 0 0
  1. local function clearScreen()
  2. term.clear()
  3. term.setCursorPos(1, 1)
  4. end
  5.  
  6. local function readConfig()
  7. local file = fs.open("/config.txt", "r")
  8. if file then
  9. local content = file.readAll()
  10. file.close()
  11. return content
  12. end
  13. return ""
  14. end
  15.  
  16. local function writeConfig(content)
  17. local file = fs.open("/config.txt", "w")
  18. if file then
  19. file.write(content)
  20. file.close()
  21. end
  22. end
  23.  
  24. local function setSecurityPassword()
  25. clearScreen()
  26. print("Enter the new security password:")
  27. local newPassword = io.read()
  28.  
  29. writeConfig(newPassword)
  30.  
  31. print("Security password set successfully.")
  32. sleep(2)
  33. end
  34.  
  35. local function removeSecurityPassword()
  36. clearScreen()
  37. local content = readConfig()
  38.  
  39. if content ~= "false" then
  40. writeConfig("false")
  41. print("Security password removed successfully.")
  42. else
  43. print("No security password set. Unable to remove.")
  44. end
  45.  
  46. sleep(2)
  47. end
  48.  
  49. local function resetSecurityPassword()
  50. clearScreen()
  51. local content = readConfig()
  52.  
  53. if content ~= "false" then
  54. print("Enter the new security password:")
  55. local newPassword = io.read()
  56.  
  57. writeConfig(newPassword)
  58.  
  59. print("Security password reset successfully.")
  60. else
  61. print("No security password set. Unable to reset.")
  62. end
  63.  
  64. sleep(2)
  65. end
  66.  
  67. local function fullSystemRecovery()
  68. clearScreen()
  69. shell.run("delete /disk")
  70. shell.run("copy /recovery /disk")
  71. print("Full System Recovery completed.")
  72. sleep(2) -- Adding a delay for visibility
  73. end
  74.  
  75. local function refreshRecoveryPartition()
  76. clearScreen()
  77. print("Please insert Doggy OS disk!")
  78.  
  79. while not fs.exists("/disk2/") do
  80. sleep(1)
  81. end
  82.  
  83. shell.run("delete /recovery")
  84. shell.run("copy /disk2 /recovery")
  85. print("Recovery partition refreshed.")
  86. sleep(2) -- Adding a delay for visibility
  87. end
  88.  
  89. local function installUpdateFromDisk()
  90. clearScreen()
  91. print("Please insert Doggy OS disk!")
  92.  
  93. while not fs.exists("/disk2/") do
  94. sleep(1)
  95. end
  96.  
  97. shell.run("delete /disk")
  98. shell.run("copy /disk2 /disk")
  99. print("Update installed from disk.")
  100. sleep(2) -- Adding a delay for visibility
  101. end
  102.  
  103. -- Main loop
  104. while true do
  105. clearScreen()
  106. print("Doggy OS Main Menu:")
  107. print("1. Recovery Options")
  108. print("2. Power Options")
  109. print("3. Security")
  110.  
  111. local mainChoice = tonumber(io.read())
  112.  
  113. if mainChoice == 1 then
  114. while true do
  115. clearScreen()
  116. term.setCursorPos(1, 1)
  117. print("Recovery Options:")
  118. print("1. Full System Recovery")
  119. print("2. Refresh Recovery Partition")
  120. print("3. Install Update from Disk")
  121. print("4. Back")
  122.  
  123. local recoveryChoice = tonumber(io.read())
  124.  
  125. if recoveryChoice == 1 then
  126. fullSystemRecovery()
  127. elseif recoveryChoice == 2 then
  128. refreshRecoveryPartition()
  129. elseif recoveryChoice == 3 then
  130. installUpdateFromDisk()
  131. elseif recoveryChoice == 4 then
  132. break -- Go back to the main menu
  133. else
  134. print("Invalid choice.")
  135. sleep(2) -- Adding a delay for visibility
  136. end
  137. end
  138. elseif mainChoice == 2 then
  139. clearScreen()
  140. term.setCursorPos(1, 1)
  141. print("Power Options:")
  142. print("1. Reboot system")
  143. print("2. Shutdown system")
  144.  
  145. local powerChoice = tonumber(io.read())
  146.  
  147. if powerChoice == 1 then
  148. os.reboot()
  149. elseif powerChoice == 2 then
  150. os.shutdown()
  151. else
  152. print("Invalid choice.")
  153. sleep(2) -- Adding a delay for visibility
  154. end
  155. elseif mainChoice == 3 then
  156. while true do
  157. clearScreen()
  158. term.setCursorPos(1, 1)
  159. print("Security Options:")
  160. print("1. Set Security Password")
  161. print("2. Remove Security Password")
  162. print("3. Reset Security Password")
  163. print("4. Back")
  164.  
  165. local securityChoice = tonumber(io.read())
  166.  
  167. if securityChoice == 1 then
  168. setSecurityPassword()
  169. elseif securityChoice == 2 then
  170. removeSecurityPassword()
  171. elseif securityChoice == 3 then
  172. resetSecurityPassword()
  173. elseif securityChoice == 4 then
  174. break -- Go back to the main menu
  175. else
  176. print("Invalid choice.")
  177. sleep(2) -- Adding a delay for visibility
  178. end
  179. end
  180. else
  181. print("Invalid choice. Please try again.")
  182. sleep(2) -- Adding a delay for visibility
  183. end
  184. end
  185.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement