X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=scripts%2Freport-spam;h=325f57183d2a14bb1365f45af1c949c246c79e22;hb=21fcd8a37c82c1ef654d402cf592f0c9d803aa26;hp=825855b543d16261bd7b6e6e1e58b1cd9e957290;hpb=3e96cf129ba5fc2834b691314c504aa363fd5cf4;p=public-inbox.git diff --git a/scripts/report-spam b/scripts/report-spam index 825855b5..325f5718 100755 --- a/scripts/report-spam +++ b/scripts/report-spam @@ -1,11 +1,11 @@ #!/bin/sh -# Copyright (C) 2008-2013, Eric Wong -# License: GPLv3 or later +# Copyright (C) 2008-2014, Eric Wong +# License: GPLv3 or later # Usage: report-spam /path/to/message/in/maildir +# This is intended for use with incron or similar systems. # my incrontab(5) looks like this: -# /path/to/.maildir/cur IN_MOVED_TO /path/to/report-spam $@/$# -# /path/to/.maildir/.INBOX.good/cur IN_MOVED_TO /path/to/report-spam $@/$# -# /path/to/.maildir/.INBOX.spam/cur IN_MOVED_TO /path/to/report-spam $@/$# +# /path/to/maildir/.INBOX.good/cur IN_MOVED_TO /path/to/report-spam $@/$# +# /path/to/maildir/.INBOX.spam/cur IN_MOVED_TO /path/to/report-spam $@/$# # gigantic emails tend not to be spam (but they suck anyways...) bytes=$(stat -c %s $1) @@ -14,15 +14,32 @@ then exit fi -# only tested with the /usr/sbin/sendmail which ships with postfix +# Only tested with the /usr/sbin/sendmail which ships with postfix +# *** Why not call spamc directly in this script? *** +# I route this through my MTA so it gets queued properly. +# incrond has no concurrency limits and will fork a new process on +# every single event, which sucks with rename storms when a client +# commits folder changes. The sendmail executable exits quickly and +# queues up the message for training. This should also ensure fairness +# to newly arriving mail. Instead of installing/configuring +# another queueing system, I reuse the queue in the MTA. +# See scripts/dc-dlvr for corresponding trainspam/trainham handlers, +# which are for my personal bayes training, and scripts/dc-dlvr.pre +# for the pispam/piham handlers for training emails going to public-inbox + +DO_SENDMAIL='/usr/sbin/sendmail -oi' +PI_USER=pi + case $1 in *[/.]spam/cur/*) # non-new messages in spam get trained - exec /usr/sbin/sendmail -oem -oi $USER+trainspam < $1 + $DO_SENDMAIL $PI_USER+pispam <$1 + exec $DO_SENDMAIL $USER+trainspam <$1 ;; *:2,*S*) # otherwise, seen messages only case $1 in *:2,*T*) exit 0 ;; # ignore trashed messages esac - exec /usr/sbin/sendmail -oem -oi $USER+trainham < $1 + $DO_SENDMAIL $PI_USER+piham <$1 + exec $DO_SENDMAIL $USER+trainham <$1 ;; esac