yeeeeeeeeeeeee

asdfg

Aug 9th, 2025
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. -- wipe_daemon.lua
  2. local keepFile = "wipe_daemon.lua" -- The file that survives
  3. local intervalDays = 10 -- Days between wipes
  4. local timeFile = ".last_wipe_time" -- Hidden file to track last wipe
  5. local checkIntervalMinutes = 30 -- How often to check (in minutes)
  6.  
  7. -- Current UTC time in ms
  8. local function currentTime()
  9. return os.epoch("utc")
  10. end
  11.  
  12. -- Should we wipe?
  13. local function shouldWipe()
  14. if not fs.exists(timeFile) then
  15. return true
  16. end
  17. local file = fs.open(timeFile, "r")
  18. local lastTime = tonumber(file.readAll())
  19. file.close()
  20. local elapsed = (currentTime() - lastTime) / (1000 * 60 * 60 * 24)
  21. return elapsed >= intervalDays
  22. end
  23.  
  24. -- Record last wipe time
  25. local function recordWipeTime()
  26. local file = fs.open(timeFile, "w")
  27. file.write(tostring(currentTime()))
  28. file.close()
  29. end
  30.  
  31. -- Wipe all files except the keeper and the time file
  32. local function wipeFiles()
  33. for _, name in ipairs(fs.list("/")) do
  34. if name ~= keepFile and name ~= timeFile then
  35. fs.delete(name)
  36. end
  37. end
  38. recordWipeTime()
  39. end
  40.  
  41. -- Main loop
  42. while true do
  43. if shouldWipe() then
  44. wipeFiles()
  45. end
  46. sleep(checkIntervalMinutes * 60) -- Wait before checking again
  47. end
Advertisement
Add Comment
Please, Sign In to add comment