Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Define directories to monitor
- local monitoredDirs = {"/disk/os/", "/disk/boot/", "/disk/bootloader/"}
- -- Function to get all files in a directory
- local function listFiles(dir)
- local files = {}
- local handle = fs.list(dir)
- for _, file in ipairs(handle) do
- table.insert(files, file)
- end
- return files
- end
- -- Function to create a snapshot of all files in monitored directories
- local function createSnapshot()
- local snapshot = {}
- for _, dir in ipairs(monitoredDirs) do
- snapshot[dir] = listFiles(dir)
- end
- return snapshot
- end
- -- Function to check if any files were deleted
- local function checkForDeletions(snapshot)
- for dir, oldFiles in pairs(snapshot) do
- local currentFiles = listFiles(dir)
- for _, oldFile in ipairs(oldFiles) do
- local exists = false
- for _, currentFile in ipairs(currentFiles) do
- if oldFile == currentFile then
- exists = true
- break
- end
- end
- if not exists then
- return true
- end
- end
- end
- return false
- end
- -- Function to switch to a specific tab
- local function switchToTab(tabName)
- -- Placeholder for tab switching logic
- -- Replace this with the actual code to switch tabs
- print("Switching to tab: " .. tabName)
- -- Example: tabSystem.switch(tabName)
- end
- -- Main program
- local function main()
- local snapshot = createSnapshot()
- while true do
- sleep(1) -- Check every second
- if checkForDeletions(snapshot) then
- term.clear()
- term.setCursorPos(1, 1)
- print("=================")
- print("Doggy OS Crash Manager")
- print("=================")
- print("")
- print("The System Has Crashed!")
- print("----------------------------")
- -- Switch to the secure tab
- switchToTab("secure")
- print("")
- print("Press Enter to reboot the system...")
- read() -- Wait for the user to press Enter
- os.reboot() -- Reboot the system
- return
- end
- end
- end
- -- Run the main program
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement