I use this script for review. For a correct result Dovecot should not run.
#!/bin/bash
attdir="/var/files/attachments" maildir="/var/mail"
cd "$attdir" || exit 1 find -type f -printf "%P\n" | grep -v "hashes" | sort -u
"$maildir/attachments.s" cd "$maildir" || exit 2 rm "$maildir/files.ok" "$maildir/files.fail" 2>/dev/null for f in $(find -type f -name "m.*" -printf "%P\n"); do doveadm dump -t dbox "$f" | egrep "^msg.ext-ref" | while read z; do set -- $z while [ -n "$1" ]; do if [[ $1 == */* ]]; then test -r "$attdir/$1" && echo "$1" >>"$maildir/files.ok" || echo "$1" >>"$maildir/files.fail" fi shift done done done sort -u "$maildir/files.ok" >"$maildir/files.s" diff -Nu "$maildir/attachments.s" "$maildir/files.s" | tee "$maildir/files.diff" | egrep "^\-"
Am 03.03.2015 um 22:08 schrieb Daniel Miller:
This seems simple enough...I'm just not script wizard. If someone can throw together a starting point I can test and tweak it from there.
It seems to me:
- Read /var/mail/mail.err or specified logfile
- For each "failed: read(/var/mail/attachments/aa/bb/attachmentHash-userHash" line, a. Confirm /var/mail/attachments/aa/bb/hashes/attachmentHash exists i. If attachmentHash is missing display such for possible backup searching. b. create link attachmentHash-userHash to hashes/attachmentHash
- Continue to end of file
Can this be done via "pure" BASH? Need sed/awk as well?