# pm-jadup.rc -- Procmail: Handle duplicates; store to separate folder # $Id: pm-jadup.rc,v 2.4 2004/04/04 16:59:05 jaalto Exp $ # # File id # # .Copyright (C) 1997-2004 Jari Aalto # .$Keywords: procmail, subroutine, filter duplicates $ # # This code is free software in terms of GNU Gen. pub. Lic. v2 or later # Refer to http://www.gnu.org/copyleft/gpl.html # # Description # # This recipe stores duplicate messages to separate folder # # Required settings # # PMSRC must point to source directory of procmail code. This subroutine # will include # # o pm-javar.rc # o pm-jastore.rc # # Call arguments (variables to set before calling) # # o JA_ID_CACHE, Where to keep the Message-Id cache. # o JA_ID_CACHE_SIZE, how big cache, defualt is 8192 # o JA_ID_MBOX, where to store duplicate messages # when delivering message to duplicate mbox. # o JA_ID_IGNORE, if set to "yes", then ignore duplicate check # # Return values # # o Variable ERROR is set to "yes" if duplicate message was trapped, # otherwise value is "no" # # Usage Example # # For simple usage, just put this somewhere after backup recipes # # RC_DUP = $PMSRC/pm-jadup.rc # ... # INCLUDERC = $RC_DUP # # When you are testing messages, you send them over and over to # .procmailrc; which means that same message should not be trapped by # duplicate check. You can call `procmail' with option "-a test" which will # set pseudo variable `$1'. The recipe below sets flag `JA_ID_IGNORE' # to "yes" if test is on going and the duplicate filter should be # bypassed. # # RC_DUP = $PMSRC/pm-jadup.rc # ARG = $1 # Copy pseudo variable to $ARG # # :0 # * ARG ?? test # { # JA_ID_IGNORE = "yes" # } # # # Some microsoft product is known to send same message ids # # over and over. If we detect one, tunr off the duplicate test, # # because it would trash every message. # # # # :0 # * ! ^X-msmail # * ! ^Message-ID: * # { # JA_ID_IGNORE = "yes" # } # # # Run this command every time a duplicate message is found. # # It writes a small log entry to MY_LOG # # INCLUDERC = $RC_DUP # # :0 hwic: # * ERROR ?? yes # | echo " [duplicate]" >> $BIFF # # Change Log: (none) # ............................................................ &code ... id = "pm-jadup.rc" dummy = " ======================================================================== $id: init: " :0 * ! WSPC ?? ( ) { INCLUDERC = $PMSRC/pm-javar.rc } # ..................................................... &output-vars ... # output variables ERROR = "no" # .......................................................... &public ... JA_ID_CACHE = ${JA_ID_CACHE:-"$HOME/pm-msgid.cache"} JA_ID_CACHE_SIZE = ${JA_ID_CACHE_SIZE:-8192} JA_ID_MBOX = ${JA_ID_MBOX:-"junk.duplicates"} JA_ID_IGNORE = ${JA_ID_IGNORE:-"no"} # ........................................................... &do-it ... # We need regional lock, because `formail' is run in condition statement. jaDupLOCKFILE = $LOCKFILE # save old lockfile LOCKFILE = ${JA_ID_CACHE}.lock :0 * ^Message-Id: * JA_ID_IGNORE ?? no * ? $FORMAIL -D $JA_ID_CACHE_SIZE $JA_ID_CACHE { ERROR = "yes" # Flag duplicate to caller MBOX = $JA_ID_MBOX INCLUDERC = $PMSRC/pm-jastore.rc } LOCKFILE = $jaDupLOCKFILE # restore value dummy = "$id: end: (DUPLICATE status = $ERROR)" # end of file