Advertisement
DOGGYWOOF

Untitled

May 25th, 2024
7
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. -- Define directories to monitor
  2. local monitoredDirs = {"/disk/os/", "/disk/boot/", "/disk/bootloader/"}
  3.  
  4. -- Function to get all files in a directory
  5. local function listFiles(dir)
  6. local files = {}
  7. local handle = fs.list(dir)
  8. for _, file in ipairs(handle) do
  9. table.insert(files, file)
  10. end
  11. return files
  12. end
  13.  
  14. -- Function to create a snapshot of all files in monitored directories
  15. local function createSnapshot()
  16. local snapshot = {}
  17. for _, dir in ipairs(monitoredDirs) do
  18. snapshot[dir] = listFiles(dir)
  19. end
  20. return snapshot
  21. end
  22.  
  23. -- Function to check if any files were deleted
  24. local function checkForDeletions(snapshot)
  25. for dir, oldFiles in pairs(snapshot) do
  26. local currentFiles = listFiles(dir)
  27. for _, oldFile in ipairs(oldFiles) do
  28. local exists = false
  29. for _, currentFile in ipairs(currentFiles) do
  30. if oldFile == currentFile then
  31. exists = true
  32. break
  33. end
  34. end
  35. if not exists then
  36. return true
  37. end
  38. end
  39. end
  40. return false
  41. end
  42.  
  43. -- Function to switch to a specific tab
  44. local function switchToTab(tabName)
  45. -- Placeholder for tab switching logic
  46. -- Replace this with the actual code to switch tabs
  47. print("Switching to tab: " .. tabName)
  48. -- Example: tabSystem.switch(tabName)
  49. end
  50.  
  51. -- Main program
  52. local function main()
  53. local snapshot = createSnapshot()
  54. while true do
  55. sleep(1) -- Check every second
  56. if checkForDeletions(snapshot) then
  57. term.clear()
  58. term.setCursorPos(1, 1)
  59. print("=================")
  60. print("Doggy OS Crash Manager")
  61. print("=================")
  62. print("")
  63. print("The System Has Crashed!")
  64. print("----------------------------")
  65. -- Switch to the secure tab
  66. switchToTab("secure")
  67. print("")
  68. print("Press Enter to reboot the system...")
  69. read() -- Wait for the user to press Enter
  70. os.reboot() -- Reboot the system
  71. return
  72. end
  73. end
  74. end
  75.  
  76. -- Run the main program
  77. main()
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement