# ~jhs/public_html/dots/Makefile by Julian Stacey PEOPLE_INC = ${HOME}/.procmailrc.people.inc SPAM_INC = ${HOME}/.procmailrc.spam.inc all: index.html ${SPAM_INC} ${PEOPLE_INC} # not using default html_links warn: -ls -l .kde/share/apps/knotes/notes/knote* @# file "knote 1" has a space in the name, which is a bloody nuisance ! .rhosts.for_export: ../../.rhosts.master echo "Dummy" > $@ chmod 600 $@ #grep -v ^# ../../.rhosts.master > $@ BLA!= cd ${.CURDIR} ; find . -type f -print0 \( ! -name index.html -and ! -name index.lmth.tmp \) index.lmth: ${BLA} Makefile echo "
Generated `date` by " >> $@
echo "Makefile
" >> $@
echo "(Generated " >> $@
echo "because web servers do not list dot files.)
" >> $@ echo "
' >> $@
chmod 644 $@
Xdefaults:
le -d .Xdefaults.master > .Xdefaults.desk
le -w .Xdefaults.master > .Xdefaults.wall
le -p .Xdefaults.master > .Xdefaults.phil
le -c .Xdefaults.master > .Xdefaults.chris
ln .Xdefaults.desk .Xdefaults
# le -`hostname` .Xdefaults.master > .Xdefaults
# ../../.DOTS/
DOMAINS_SRC = .procmailrc.domains.src
PEOPLE_SRC = ${HOME}/.procmailrc.people.src
# ${HOME} as these are private files not web exported.
PHRASES_SRC = ${HOME}/.procmailrc.phrases.src
SPAM_SHRUNK = ${HOME}/.procmailrc.spam_shrunk
vi: # cd ~/public_html/dots; make vi
# Edits in new phrases & domains while reading mail.
make ${SPAM_INC} ${PEOPLE_INC}
make sort
vi ${PEOPLE_SRC} ${PHRASES_SRC} /host/conf/site/etc/mail/domains2block
@# ${DOMAINS_SRC} -> /site/etc/mail/domains2block
@# If you do not run this on /host/conf your edits to /site
@# will get discarded later.
make sort
make
${PEOPLE_INC}: ${PEOPLE_SRC} Makefile
@echo "# ${PEOPLE_INC}" > $@
@echo "# DO NOT EDIT, created by ~/public_html/dots/Makefile" \
>> $@
@echo "# from ${PEOPLE_SRC}" >> $@
@echo "# Divert known people" >> $@
@# Names such as eg "John Smith" I list as "John.Smith" which
@# matches both "John Smith" at home and john.smith@company.com
for i in `awk -F : '{printf "%s\n",$$1}' ${PEOPLE_SRC}` ; do \
echo ":0 Hw" >> $@ ; \
echo "* ^From:.*$$i" >> $@ ; \
echo " {" >> $@ ; \
echo " :0 wc # Place in mbox." >> $@ ; \
echo ' | $$RCVSTORE +Inbox' >> $@ ; \
echo " :0 Wc # Store recent 100." >> $@ ; \
echo " .Recent" >> $@ ; \
echo " :0 Wic # Keep .Recent/ down to 100." >> $@ ; \
echo ' | cd .Recent && rm -f dummy `ls -t msg.* | sed -e 1,100d`' >> $@ ; \
echo " :0 W # Raise flag & ring bell." >> $@ ; \
echo ' $$MAILDIR/.xbiff' >> $@ ; \
echo " }" >> $@ ; \
done
@echo "Caution: if ${PEOPLE_SRC} has spaces in 1st column"
@echo "between 1st & last names, it emits 2 bad filters instead of"
@echo "a single line more complex name in ${PEOPLE_INC}"
# JJLATER sed sample copied from .procmailrc for above:
# | cd .Recent && rm -f dummy `ls -t msg.* | sed -e 1,100d`
sort:
make sort-phrases sort-people
rsh conf "cd public_html/dots ; make sort-domain"
@# rsh as ${DOMAINS_SRC} is a sym link to /site, & if we
@# update any other host, rdist from host=conf will zap it later.
sort-phrases:
cat ${PHRASES_SRC} | \
tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | \
sort | uniq | grep -v "^$$" > $@.tmp
if ( test -s $@.tmp && ! cmp -s $@.tmp ${PHRASES_SRC} ) ; \
then \
cat $@.tmp > ${PHRASES_SRC} ; \
rm $@.tmp ; \
echo "${PHRASES_SRC} now sorted" ; \
else \
echo -n "No difference (or zero size), " ; \
echo "so not updating ${PHRASES_SRC}" ; \
rm $@.tmp ; \
fi
sort-people:
cat ${PEOPLE_SRC} | \
sort | uniq | grep -v "^$$" > $@.tmp
# maybe later: tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
if ( test -s $@.tmp && ! cmp -s $@.tmp ${PEOPLE_SRC} ) ; \
then \
cat $@.tmp > ${PEOPLE_SRC} ; \
rm $@.tmp ; \
echo "${PEOPLE_SRC} now sorted" ; \
else \
echo -n "No difference (or zero size), " ; \
echo "so not updating ${PEOPLE_SRC}" ; \
rm $@.tmp ; \
fi
sort-domain:
cat ${DOMAINS_SRC} | \
tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz \
| sort | uniq | grep -v "^$$" | grep -v "^10\\." \
| grep -v "^192\\.168\\." | grep -v "^172\\.16\\." \
| grep -v 83.236.223.114 | grep -v 83.236.223.115 \
| grep -v 194.246.123.68 | grep -v t-dialin.net \
| grep -v dsl.sntc01.pacbell.net \
| grep -v " " \
> $@.tmp
if ( test -s $@.tmp && ! cmp -s $@.tmp ${DOMAINS_SRC} ) ; \
then \
cp $@.tmp ${.CURDIR}/${DOMAINS_SRC} && \
rm $@.tmp ; \
echo "${DOMAINS_SRC} now sorted" ; \
else \
echo -n "No difference (or zero size), " ; \
echo "so not updating ${DOMAINS_SRC}" ; \
rm $@.tmp ; \
fi
@# cp rather than move as ${DOMAINS_SRC} --> /site/...
@# The cp may fail if /site/etc/mail/domains2block is not uid=jhs,
@# I'd like to add dip.t-dialin.net to the block list,
@# but that would block me.
@# I ensure I havent included internal private IP ranges from spammers,
@# that other innocents elsewhere will also use, by deleting
@# 10.*.*.* & 192.168.*.* & 172.16.0.0-172.31.255.255
@# The other IPs are numbers I might paste by mistake.
grepspam_hook: ${SPAM_SHRUNK} # Hook for ~jhs/bin/.sh/grepspam
# Remove blank lines from ${SPAM_SHRUNK}, else they get turned into
# a match line in ${SPAM_INC} consisting of a simple "* "
# which matches all lines, & personal mail gets dumped in spam box.
# Later phrases may be fed into a different anti spam tool, so preserve
# the original list, & copy & reduce to a safer form for procmail.
${SPAM_SHRUNK}: ${PHRASES_SRC} Makefile
cat ${PHRASES_SRC} | grep -v "^$$" > $@
@# maybe later add here a global sed space to \s
SPAM_TMP = ${HOME}/tmp/.procmailrc.spam.tmp
# SPAM_TMP achieves a Massive speed-up, avoiding 5000 slow small nfs
# appends to ~/dots/${SPAM_INC}
${SPAM_INC}: ${SPAM_SHRUNK} Makefile # ${DOMAINS_SRC}
echo "# ~/dots/$@ built by ~/dots/Makefile" > $@
@echo "# Do Not Edit: Built by ~/public_html/dots/Makefile" >> $@
@echo "# Included by ~/.procmailrc.private" >> $@
@echo "# Phrases: From ~/dots/${PHRASES_SRC}" >> $@
@# "Warning phrases such as h.o.t. false match to olt in Ashbolt"
@# "Warning phrases such as i.r.a.q false match mime encoded pics"
cp /dev/null ${SPAM_TMP}
cat ${SPAM_SHRUNK} | \
while read phrase ; do \
echo ":0 BHW" >> ${SPAM_TMP} ;\
echo -n "* " >> ${SPAM_TMP} ;\
echo $$phrase >> ${SPAM_TMP} ;\
echo 'spam/phrases/.' >> ${SPAM_TMP} ;\
done
@# 2 lines above here, choose 1 of these 2:
@# echo '| $$RCVSTORE +spam/phrases' >> ${SPAM_TMP} ;
@# Raises EXMH Blue highlighting
@# echo 'spam/phrases/.' >> ${SPAM_TMP} ;
@# No EXMH blue highlighting of new spams
cat ${SPAM_TMP} >> $@
@# Do not "rm ${SPAM_SHRUNK}" as useful for grepspam.
@# ----------------
@# @echo "# Domains: From ~/dots/${DOMAINS_SRC}" >> $@
@# Next commented out as:
@# @# - short domains create false matches, particulalrly on binary enclosures.
@# @# - domain "this.com" used to falsely match against non spam
@# @# email which had "this complaint" in the body, so
@# @# I reduced ":0 BH" below to just
@# @# ":0 H", however thats not good enough,
@# @# JJLATER I should delimit all "." to
@# @# tell procmail its a literal string
@# cp /dev/null ${SPAM_TMP}
@# cat ${DOMAINS_SRC} | \
@# while read domain ; do \
@# echo ":0 H" >> ${SPAM_TMP} ;\
@# echo "* ^Received:.*$$domain" >> ${SPAM_TMP} ;\
@# echo '| $$RCVSTORE +spam/domain' >> ${SPAM_TMP} ;\
@# done
@# cat ${SPAM_TMP} >> $@
@ rm ${SPAM_TMP}
@# If code above is re-enabled to use ${DOMAINS_SRC}, then also
@# add .procmailrc.domains.src to phrases in ~/bin/.sh/grepspam
# Some manually called label, not used in a while.
check: ${SPAM_SHRUNK} ${DOMAINS_SRC} Makefile
@# Search for domains first, as thats more likely troublesome.
@# Limitation: this does not search domains of lists maintained by
@# majordomo on the remote servers.
@# The '-' in next line is necessary to avoid first non matching
@# line stopping the while loop.
@# Do not "rm ${SPAM_SHRUNK}" as useful for grepspam.
-cat ${DOMAINS_SRC} | \
while read domain ; do \
echo "Searching for $$domain" > /dev/null ;\
(cd /site ; xs Grep $$domain |\
grep -v ./etc/mail/domains2block: |\
grep -v ./domain/js.berklix.net/etc/mail/access: |\
grep -v ./domain/berklix/etc/mail/access \
) ;\
done
echo "make not_yet_ready still needs to be developed."
not_yet_ready:
@# the domain marked DISCARD above is typically a line such as:
@# ./domain/js.berklix.net/etc/mail/access:best-deals2u.biz DISCARD
@# Search for phrases.
-cat ${SPAM_SHRUNK} | \
while read phrase ; do \
echo Seeking for "\"$$phrase\"" ;\
(cd /site ; xs Grep "\"$$phrase\"" ) ;\
sleep 10 ;\
done
PROCM = .procmailrc
PROCM += .procmailrc.3d
PROCM += .procmailrc.errors
PROCM += .procmailrc.fonts
PROCM += .procmailrc.lists
PROCM += .procmailrc.lists
PROCM += .procmailrc.owner_dump
PROCM += .procmailrc.owner_keep
PROCM += .procmailrc.private_dump
PROCM += .procmailrc.private_keep
PROCM += .procmailrc.private_self
PROCM += .procmailrc.system_logs
PROCM += .procmailrc.web_form
# ${DOMAINS_SRC} ${PHRASES_SRC}:
# No command lines, just text, automaticaly sorted by Makefile.
# ${SPAM_INC}:
# Generated by Makefile.
PLOG = $$HOME/mail/procfile.log
brackets:
@# test for unmatched bracket count on .procmailrc files
@# theres''s a lot more syntax checking could be done than this,
@# but it''s a start, & also ${PLOG} catches errors
cd $$HOME && for i in ${PROCM} ; do \
brackets $$i | tail -1 ;\
echo $$i ;\
echo ;\
done
log:
@echo "Checking for some errors I have noticed in .procmailrc*"
@#---------------
-grep "procmail: Invalid regexp " ${PLOG} || true
@# If a ( has not been delimited to ( & the other ) has been to \)
@#---------------
-grep "procmail: Skipped " ${PLOG} || true
@# If a ":0" line has been forgotten, preceeding a "* Match pattern".
@# true avoids the ouput nessed by "*** Error code 1 (ignored)"
@#---------------
-grep "Missing closing brace" ${PLOG} || true
@# If no action rule before an existing close brace }
@#---------------
-grep "Folder: :0" ${PLOG} || true
@# I can not remember what error produces this but I have seen it.
@#- - - - - - - -
@# If eg one has an action rule of "| $RCVSTORE +$INBOX_PLAIN"
@# & one has forgotten to define INBOX_PLAIN one get this log error:
@# "^ Folder: /usr/local/libexec/nmh/rcvstore +^I"
@# I need to add delimeter to next line
-grep "^ \\ Folder: /usr/local/libexec/nmh/rcvstore + " ${PLOG} || true
@# & one gets files such as ~/mail/1
if [ -e ~/mail/1 ] ; then \
ls -l ~/mail/[0-9]* ; \
fi
NO_OBJ= true
.include