Илья Евсеев
2006-Apr-29 00:39 UTC
[Dovecot] How to notify dovecot that maildir contents is changed by third-party helper ?
Hi, folks! How to notify dovecot that maildir contents is changed by third-party helper? My script performs spam cleanup, but all index/cache files (dovecot-uidlist, dovecot.index, dovecot.index.cache and dovecot.index.log) still unchanged, so, Web-frontend (IlohaMail over IMAP) displays taht mailbox contents isn't refreshed. Dovecot 1.0-alpha5 under FreeBSD 4.11. mail = maildir:/var/vmail/default/%1n/%n WBR, Ilya ------------------------------------------------- #!/bin/bash # # CleanupMailboxSpam # # Tracks mail directories of Dovecot IMAP server # and moves/removes all messages marked as spam by SpamAssassin: # # * When mailbox contains "KillSpam.<number>" subfolder, # all spam messages with score >= <number> are removed. # * When mailbox contains "Spam" subfolder, # all remaining spam messages are moved to this subfolder. # * When mailbox contains "KillSpam" subfolder, # all remaining spam messages are removed. # # TODO: update indexes and caches on altered mail folders!!! # # Only for testing: doit=echo; export doit; ... # This prints all modification commands instead of executing them. # # Written at Apr 2006 by evseev at sertolovo.ru # VMAIL_TOPDIR=/var/vmail FIND_DEPTH=4 # Debugging values VMAIL_TOPDIR=/var/vmail/default/e/evseev FIND_DEPTH=1 INBOX_DIRNAME=cur KILLSPAM_DIRNAME='.KillSpam' SPAM_DIRNAME='.Spam' MSGHEADLEN=30 RM="/bin/rm -f" MV="/bin/mv -f" #========= Routines ==========================================# IsSpamFile() { local msgfile="$1" score2clean="$2" local spamstatus=$(head -$MSGHEADLEN "$msgfile" | egrep '^X-Spam-Status: Yes') test -z "$spamstatus" && return 1 if [ -n "$score2clean" ]; then local spamscore=${spamstatus##*score=} spamscore=${spamscore%%.*} test "$spamscore" -lt "$score2clean" && return 1 fi return 0 } KillSpamInFolder() # $1 = kill-label folder to check { local dir2clean=$(dirname $1)/$INBOX_DIRNAME local score2clean=$(basename $1) score2clean=${score2clean##${KILLSPAM_DIRNAME}.} test "$score2clean" -ge 1 -a "$score2clean" -le 50000 > /dev/null 2>&1 || score2clean find "$dir2clean" -type f | while read f; do IsSpamFile "$f" "$score2clean" && $doit $RM "$f" done } MoveSpamToFolder() # $1 = spam folder to consume spam { local dir2check=$(dirname $1)/$INBOX_DIRNAME find "$dir2check" -type f | while read f; do IsSpamFile "$f" && $doit $MV "$f" "${1}/$INBOX_DIRNAME" done } DoOnSubFolders() # $1 = dirmask to find, $2 = action to apply { find $VMAIL_TOPDIR/ -mindepth $FIND_DEPTH -maxdepth $FIND_DEPTH \ -type d -iname "$1" \ | while read d; do "$2" "$d" done } #========= Main ==============================================# DoOnSubFolders "${KILLSPAM_DIRNAME}?*" KillSpamInFolder DoOnSubFolders "${SPAM_DIRNAME}" MoveSpamToFolder DoOnSubFolders "${KILLSPAM_DIRNAME}" KillSpamInFolder ## EOF ##
Timo Sirainen
2006-May-02 09:06 UTC
[Dovecot] How to notify dovecot that maildir contents is changed by third-party helper ?
On Sat, 2006-04-29 at 04:39 +0400, ???? ?????? wrote:> Hi, folks! > How to notify dovecot that maildir contents > is changed by third-party helper?There shouldn't be a need to do anything.> My script performs spam cleanup, > but all index/cache files (dovecot-uidlist, dovecot.index, > dovecot.index.cache and dovecot.index.log) still unchanged, > so, Web-frontend (IlohaMail over IMAP) > displays taht mailbox contents isn't refreshed.Only dovecot.index and dovecot.index.log should be changed, others might not.> Dovecot 1.0-alpha5 under FreeBSD 4.11.Hmm. What happens if you do "touch cur" after deleting the mails, are the mails noticed then? Alpha5 is somewhat old too, so it's possible that it has some bug related to this. I'd suggest trying newest beta. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: <http://dovecot.org/pipermail/dovecot/attachments/20060502/e54be02d/attachment.bin>