procmail whitelist - better way to do this?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Trying to automate the updating of my whitelist on my imap server without accidentally whitelisting a blacklisted individual who happens to be in my address book.

I'm doing this with a nightly cron script scheduled to run on my machine with my primary usage e-mail client, by having it send an e- mail to the imap server.

Here is the script I will run from cron on the machine with my mail client:

---------
#!/bin/sh

export TERM=Linux
cd /tmp
ADDRESS="$HOME/AddressBook.vcf"

MESSAGE="`mktemp whitemail.XXXX`"

echo "STARTWHITE" > ${MESSAGE}
cat ${ADDRESS} |grep INTERNET |cut -d":" -f2 >> ${MESSAGE}

mail -s "WHITELIST" mpeters@xxxxxxxxxxxxxxxxxxxxx < ${MESSAGE}
rm -f ${MESSAGE}
----------

Here is the procmail recipe on my account at utility

----------
:0:
* ^Subject.*WHITELIST
* ^From.*mpeters@xxxxxxxxxxxxxxxxxxx
| cat > $HOME/whitelist.in && $HOME/bin/whitelist.sh
----------

here is the ~/bin/whitelist.sh script

----------
#!/bin/sh
[ -f $HOME/whitelist.in ] || exit 1
[ -f $HOME/.spamassassin/user_prefs ] || exit 1

LN=`grep -n "STARTWHITE" $HOME/whitelist.in |cut -d":" -f1` || exit 1
LENGTH=`wc -l $HOME/whitelist.in |cut -d" " -f1`
TAIL=`echo "${LENGTH} - ${LN}" |bc`

tail -${TAIL} $HOME/whitelist.in |grep -v "^$" |sort |uniq > ~/.whitelist

for a in `cat ~/.whitelist`; do
if [ `grep -c "_from ${a}" $HOME/.spamassassin/user_prefs` -eq 0 ]; then
echo "whitelist_from ${a}" >> $HOME/.spamassassin/ user_prefs
fi
done
-----------


Is there a "cleaner" way to accomplish the same thing?

--
Michael A. Peters
http://mpeters.us/




[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux