Rebuilding SIS attachment links from log
Hardy Flor
HFlor at gmx.de
Wed Mar 4 17:29:00 UTC 2015
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:
>
> 1. Read /var/mail/mail.err or specified logfile
> 2. 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
> 3. Continue to end of file
>
> Can this be done via "pure" BASH? Need sed/awk as well?
>
More information about the dovecot
mailing list