heiby@mcdchg.UUCP (Ron Heiby) (05/04/88)
To much sex and drugs on the net getting you down? Tired of seeing
so many flames start to infiltrate previously sane (mostly) newsgroups?
Well, have I got a solution for you! Enjoy!
-----
#
# kill.group - Delete all articles posted or cross-posted to
# a particularly obnoxious or undesirable newsgroup.
#
# Written by Ron Heiby for his own amusement. 3/29/88
#
# There must be an opportunity between the time that news
# is un-batched and the time it is batched for downstream
# sites for this script to be run. (Simplest is to run a
# script that calls your batching routine (like sendbatch),
# but before it does, have it run this.) If you are running
# SPOOLNEWS and/or SPOOLINEWS, the call to kill.group would
# go just after the "rnews -U" line.
#
# invoke with (for example): kill.group alt.flame
#
# Any (reasonable) number of newsgroups can be specified on the
# command line and will be zapped in the order given. Sub-groups
# should be specified before parent groups for best effect.
#
HOME=`awk -F':' '/^usenet/ {print $6}' /etc/passwd` # News home directory
SPOOL=$HOME/spool/news
NAMES=/tmp/trash.$$
MYNAME=`uname`
for newsgroup in $*
do
killdir=`echo $newsgroup | tr . /`
if [ ! -d $SPOOL/$killdir ] # If no directory, nothing to do.
then
break
fi
cd $SPOOL/$killdir
if [ -z "`ls`" ] # If no files in directory,
then
break # then don't bother with anything else.
fi
# Here, we look at the header lines for each article in the group,
# looking for an Xref header line, meaning that the article was
# cross-posted and must be exterminated in multiple newsgroups.
# We specifically look only at the message header in case someone
# were to post an article full of Xref lines causing other things
# to be deleted. Also, we only look at our own system's Xref line.
# We strip off the leading crap in the Xref line, leaving only the
# newsgroup name and article number. Changing the "." and ":"
# punctuation to "/" gives us pathnames relative to $SPOOL where
# the trash can be found.
for i in *
do
sed -e '/^$/q' $i |
egrep "^Xref: $MYNAME " |
sed -e "s/Xref: $MYNAME //" -e 's/:/\//g' -e 's/\./\//g'
done > $NAMES
# Since the pathnames are relative to $SPOOL, we cd there and do the rm.
cd $SPOOL
rm `cat $NAMES`
# In case there were some articles in the group that weren't cross-posted
# to some other group, we now wipe out the directory and everything
# in it (but not sub-dirs), as well as our temp file.
rm -f $killdir/* $NAMES 2>/dev/null
rmdir $killdir 2>/dev/null
done
# Another job, well done!
exit 0
--
Ron Heiby, heiby@mcdchg.UUCP Moderator: comp.newprod & comp.unix
"I believe in the Tooth Fairy." "I believe in Santa Claus."
"I believe in the future of the Space Program."heiby@mcdchg.UUCP (Ron Heiby) (05/07/88)
Looks like I missed changing the two "break" statements to "continue"
statements when I modified kill.group to handle multiple undesirable
groups. I also added an efficiency hack (xargs) and an "-f" option
to one of the "rm" commands, in case no files were found.
----- cut here -----
#
# kill.group - Delete all articles posted or cross-posted to
# a particularly obnoxious or undesirable newsgroup.
#
# Written by Ron Heiby for his own amusement. 3/29/88
# Minor fixes, mostly for multi-group kills: 5/6/88
#
# There must be an opportunity between the time that news
# is un-batched and the time it is batched for downstream
# sites for this script to be run. (Simplest is to run a
# script that calls your batching routine (like sendbatch),
# but before it does, have it run this.) If you are running
# SPOOLNEWS and/or SPOOLINEWS, the call to kill.group would
# go just after the "rnews -U" line.
#
# invoke with (for example): kill.group alt.flame
#
# Any (reasonable) number of newsgroups can be specified on the
# command line and will be zapped in the order given. Sub-groups
# should be specified before parent groups for best effect.
#
HOME=`awk -F':' '/^usenet/ {print $6}' /etc/passwd` # News home directory
SPOOL=$HOME/spool/news
NAMES=/tmp/trash.$$
MYNAME=`uname`
for newsgroup in $*
do
killdir=`echo $newsgroup | tr . /`
if [ ! -d $SPOOL/$killdir ] # If no directory, nothing to do.
then
continue
fi
cd $SPOOL/$killdir
if [ -z "`ls`" ] # If no files in directory,
then
continue # then don't bother with anything else.
fi
# Here, we look at the header lines for each article in the group,
# looking for an Xref header line, meaning that the article was
# cross-posted and must be exterminated in multiple newsgroups.
# We specifically look only at the message header in case someone
# were to post an article full of Xref lines causing other things
# to be deleted. Also, we only look at our own system's Xref line.
# We strip off the leading crap in the Xref line, leaving only the
# newsgroup name and article number. Changing the "." and ":"
# punctuation to "/" gives us pathnames relative to $SPOOL where
# the trash can be found.
for i in *
do
sed -e '/^$/q' $i |
egrep "^Xref: $MYNAME " |
sed -e "s/Xref: $MYNAME //" -e 's/:/\//g' -e 's/\./\//g'
done > $NAMES
# Since the pathnames are relative to $SPOOL, we cd there and do the rm.
cd $SPOOL
cat $NAMES | xargs rm -f #OLD STYLE# rm -f `cat $NAMES`
# In case there were some articles in the group that weren't cross-posted
# to some other group, we now wipe out the directory and everything
# in it (but not sub-dirs), as well as our temp file.
rm -f $killdir/* $NAMES 2>/dev/null
rmdir $killdir 2>/dev/null
done
# Another job, well done!
exit 0
----- cut here -----
--
Ron Heiby, heiby@mcdchg.UUCP Moderator: comp.newprod & comp.unix
"I believe in the Tooth Fairy." "I believe in Santa Claus."
"I believe in the future of the Space Program."