You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.2KB

  1. #!/bin/sh
  2. BASE=/opt/jails
  3. OMIT=/etc:tor/data/state:.pid:access_log:error_log
  4. if [ -z "$1" ]; then
  5. JAILS=`ls -d $BASE/*/`
  6. else
  7. JAILS="$1"
  8. fi
  9. echo "[*] Omitting these patterns in filenames: '$OMIT'"
  10. for i in $JAILS; do
  11. echo "[*] Now checking '$i' ..."
  12. JAIL_OUTDATED=false
  13. JAIL_FILES=`find "$i" -type f`
  14. for file in $JAIL_FILES; do
  15. OLD_IFS=$IFS
  16. IFS=":" read -ra OMIT_PATTERNS <<< "$OMIT"
  17. skip=false
  18. for j in ${OMIT_PATTERNS[@]}; do
  19. if [[ "$file" =~ $j ]]; then
  20. skip=true
  21. continue
  22. fi
  23. done
  24. if $skip; then
  25. # echo "Skipping '$file'..."
  26. continue
  27. fi
  28. original_file="/${file/${i:-1}/}"
  29. #original_file=$(echo "$file" |sed -e "s~$i~~g")
  30. if [ ! -f "$original_file" ]; then
  31. continue
  32. fi
  33. if [ "$(md5sum "$original_file" |cut -d' ' -f1)" != "$(md5sum "$file" |cut -d' ' -f1)" ]; then
  34. echo "[!] '$file' is outdated"
  35. JAIL_OUTDATED=true
  36. fi
  37. done
  38. if $JAIL_OUTDATED; then
  39. echo "[!] Jail is outdated, TODO: code the automatic copy."
  40. else
  41. echo "[*] All good!"
  42. fi
  43. done