#!/bin/sh # # @(#)procmail_panix 1996/12/19 Anne Bennett # # Download Panix's procmailrc file for blocking spam, # reformat it for our site, and compare it to what # we've got. Report if different, and prepare new file. PATH=/local/paths:/usr/bin:/sbin:/usr/sbin export PATH thisprog=procmail_panix logger="logger -p mail.info ${thisprog}:" url="http://www.panix.com/rc.shared" cur_rc=/local/etc/procmail/spam/tag-panix new_rc=/local/etc/procmail/spam/NEW.tag-panix mailto="anne" tmp_new=/tmp/${thisprog}.$$.tmp_new tmp_old=/tmp/${thisprog}.$$.tmp_old tmp_diff=/tmp/${thisprog}.$$.tmp_diff all_tmp="${tmp_new} ${tmp_old} ${tmp_diff}" # Start. # ${logger} starting. # Download and format Panix material; note the date and time. # lynx -dump -source ${url} \ | sed -e 's/^:0:/:0 Hf/' \ -e 's/^\$TRASH/| formail -b -f -A "$trash_header siteban per-panix"/' \ > ${tmp_new} down_date=`date '+%Y/%m/%d %H:%M:%S %Z'` # Isolate our current Panix-derived material. # cat ${cur_rc} \ | sed -n '/^# ========== Panix-derived material below ==========$/,$p' \ | tail +2 \ >> ${tmp_old} # Are they different? If not, clean up and exit quietly. # diff ${tmp_old} ${tmp_new} > ${tmp_diff} if [ ! -s ${tmp_diff} ]; then # No changes. ${logger} no change. rm -f ${all_tmp} ${logger} end of run. exit fi # There were changes! Prepare a new file and notify maintainer. # ${logger} changes found. cat ${cur_rc} \ | sed -n '1,/^# ========== Panix-derived material below ==========$/p' \ | sed -e "s%^# Last download on .*%# Last download on ${down_date}%" \ > ${new_rc} cat ${tmp_new} >> ${new_rc} ${logger} notifying maintainer. ( echo "" echo "New Panix procmail data is in ${new_rc}" echo "" echo "Differences follow:" echo "" echo "====================================" echo "" cat ${tmp_diff} ) | mailx -s "New Panix procmail data ready" ${mailto} # Clean up and leave rm -f ${all_tmp} ${logger} end of run. exit