#!/bin/sh # File: emailmunge # Author: JC Lawrence, modified by me, Dominic J. Eidson # Created: Before My Time. # Last Modified: May 20th, 1999 # Description: Script for "munging" e-mail adresses, this is good if you # archive something containing lots and lots of e-mail # adresses, and don't want them to be harvested by # spam-bots. # Initial Variables DB_FILE="./.emunge.db" TMP_FILE="/tmp/`basename $0`.${$}" TMP2_FILE="/tmp/`basename $0`-2.${$}" HOLD_FILE="/tmp/`basename $0`-hold.${$}" WORK_FILE="/tmp/`basename $0`-work.${$}" #Cleanup in case of breaks. trap 'rm -f $TMP_FILE $TMP2_FILE $HOLD_FILE $WORK_FILE' 0 1 2 6 9 11 13 15 # Other files you *always* want munged OTHER_FILES="index.html author.html threads.html date.html" # The last ADDL_FILES will get munged again - this to re-munge old files # that get modified for whatever reason ADDL_FILES=5 # FIND_REGEXP is the search pattern to look for files with. FIND_REGEXP="msg[0-9][0-9][0-9][0-9][0-9].html" # initialise files if [ -f $DB_FILE ]; then cat $DB_FILE > $TMP2_FILE 2> /dev/null tail -n $ADDL_FILES $DB_FILE >> $TMP2_FILE 2> /dev/null fi cat $TMP2_FILE | sort | uniq -u > $TMP_FILE 2> /dev/null ls -1 $FIND_REGEXP 2> /dev/null >> $HOLD_FILE cat $HOLD_FILE >> $TMP_FILE if [ "$1" = "-q" ] ; then for file in `sort < $TMP_FILE | uniq -u` $OTHER_FILES do if [ -f $file ] ; then sed "s/\([a-zA-z0-9]\)@\([a-zA-Z0-9-]*\)\./\\1#\\2,/g" < $file > $file.munge 2> /dev/null mv $file.munge $file 2> /dev/null chmod 644 $file 2> /dev/null fi done else echo -n "Munging email addresses" for file in `sort < $TMP_FILE | uniq -u` $OTHER_FILES do if [ -f $file ] ; then sed "s/\([a-zA-z0-9]\)@\([a-zA-Z0-9-]*\)\./\\1#\\2,/g" < $file > $file.munge 2> /dev/null mv $file.munge $file 2> /dev/null chmod 644 $file 2> /dev/null echo -n "." fi done echo "" echo "Done." fi mv $HOLD_FILE $DB_FILE # Make sure files are go+r chmod 644 $FIND_REGEXP 2> /dev/null &