From: chip@tct.com (Chip Salzenberg)
Subject: Re: My C News newgroup/rmgroup scripts, 2 Nov 92 version
Date: Sun, 8 Nov 1992 17:08:31 GMT
Organization: TC Telemanagement, Clearwater, FL

According to twpierce@unix.amherst.edu (Tim Pierce):
>I think that I am on the verge of implementing Chip Salzenberg's C
>news newgroup/rmgroup scripts.

Thanks for the advertising.  The 2 November 1992 scripts are below.
---------------------------------------------------------------------
[ NOTE: This version (of 2 November 1992) fixes a bug in the previous
  (27 October 1992) release of these scripts.  They didn't scan the
  "ignore.groups" file properly unless each line in it had a trailing
  space.  This version should be Feeling Much Better.]

The below C News newgroup and rmgroup scripts do nothing except send
mail to the Usenet administrator.  No more hassles from alt.crybabies.
Also, improving on previous releases, these scripts allow you to
ignore unwanted control messages with two files in $NEWSCTL (typically
"/usr/lib/news"):

 ignore.groups    Groups to ignore, one per line (ie. alt.graphics)
 ignore.pats      Egrep patterns for headers to ignore, one per line
                  e.g. "^Path:.*!feline!"

Shar and enjoy.

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  newgroup rmgroup
# Wrapped by chip@animal on Mon Nov  2 13:25:48 1992
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'newgroup' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'newgroup'\"
else
echo shar: Extracting \"'newgroup'\" \(3198 characters\)
sed "s/^X//" >'newgroup' <<'END_OF_FILE'
X#! /bin/sh
X# newgroup group flag
X#	subject to our sys file group pattern
X#
X#----------------------------------------------------------------------------
X# READ THIS FIRST:
X# Be sure to modify the definition of NEWSCONFIG appropriately.
X# Also, if you're on a BSD-derived system, you will probably need to
X# change the definition of $MAIL from "mail" to "Mail".
X#----------------------------------------------------------------------------
X#
X# Modified by Chip Salzenberg, 2 November 1992
X# Fix typo in processing of "$NEWSCTL/ignore.groups".
X#
X# Modified by Chip Salzenberg, 27 October 1992
X# Ignore messages for articles matched by "$NEWSCTL/ignore.pats".
X#
X# Modified by Chip Salzenberg, 19 October 1992
X# Ignore messages for groups named in "$NEWSCTL/ignore.groups".
X#
X# Modified by Chip Salzenberg, 21 November 1990
X# Settle "mail" vs. "Mail" with the $MAIL variable.
X# Combine all possibilities into one mail statement.
X#
X# Modified by David C Lawrence, 25 August 1990
X# Include whole article.  Fixed testing for change of status.
X#
X# Modified by Bill Wisner, 23 August 1990
X# Properly handle changes in moderation status.
X#
X# Modified by Chip Salzenberg, 7 June 1990.
X# Send mail to Usenet administrator describing the newgroup request.
X# But if group already exists with correct type, don't bother.
X#
X
X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
X. ${NEWSCONFIG-/usr/lib/news/bin/config}
Xexport NEWSCTL NEWSBIN NEWSARTS
XPATH=$NEWSCTL/bin:$NEWSBIN/relay:$NEWSBIN:$NEWSPATH ; export PATH # include mkpdir
Xumask $NEWSUMASK
X
XMAIL=mail
X
Xafile=/tmp/ncd
Xafilehdr=${afile}hdr
Xafilebody=${afile}body
Xhdr=/tmp/nc$$
X
Xtrap "exit 1" 1 2 3 13 15
Xtrap "rm -f $hdr $afilehdr $afilebody" 0
X
X$NEWSBIN/inject/tear $afile
X$NEWSBIN/canonhdr <$afilehdr >$hdr
X
X# unapproved ctl msg? then quit
Xegrep '^Approved:' $hdr >/dev/null || exit 1
X
X# figure an egrep pattern for the group
Xpat="`echo $1 | sed 's/[+\.]/\\\\&/g'`"
X
X# quit if the group is a bone of contention
Xf=$NEWSCTL/ignore.groups
Xtest -f $f && egrep "^$pat\$" $f >/dev/null && exit 0
X
X# quit if an admin-written pattern matches
Xf=$NEWSCTL/ignore.pats
Xtest -f $f && egrep -f $f $hdr >/dev/null && exit 0
X
X# quit if the group already exists in the form requested
Xtype=`awk "/^$pat / { print \\$4; exit }" $NEWSCTL/active`
X
Xcase "$type" in
Xx|=*)	exit 0 ;;
Xy)	test "" = "$2" && exit 0 ;;
Xm)	test "moderated" = "$2" && exit 0 ;;
Xesac
X
X# determine who sent the message
XSENDER="`grep '^Sender:' $hdr | sed 's/^[^:]*: *//'`"
Xcase "$SENDER" in
X"")	SENDER="`grep '^From:' $hdr | sed 's/^[^:]*: *//' `" ;;
Xesac
X
Xif test "y" = "$type" -a "moderated" = "$2"; then
X	subject="Make $1 moderated"
X	killme="change the group '$1' from unmoderated to moderated"
Xelif test "m" = "$type" -a "moderated" != "$2"; then
X	subject="Make $1 unmoderated"
X	killme="change the group '$1' from moderated to unmoderated"
Xelse
X	subject="Create $1 $2"
X	if test "moderated" = "$2"; then
X		killme="create the moderated group '$1'"
X	else
X		killme="create the group '$1'"
X	fi
Xfi
X
X( echo "$SENDER says"
X  echo "to $killme"
X  echo "in this article:"
X  echo "================================================================"
X  cat $afilehdr $afilebody ) |
X    $MAIL -s "$subject" "$NEWSMASTER"
Xexit 0
END_OF_FILE
if test 3198 -ne `wc -c <'newgroup'`; then
    echo shar: \"'newgroup'\" unpacked with wrong size!
fi
chmod +x 'newgroup'
# end of 'newgroup'
fi
if test -f 'rmgroup' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'rmgroup'\"
else
echo shar: Extracting \"'rmgroup'\" \(2349 characters\)
sed "s/^X//" >'rmgroup' <<'END_OF_FILE'
X#! /bin/sh
X# rmgroup group
X#
X#----------------------------------------------------------------------------
X# READ THIS FIRST:
X# Be sure to modify the definition of NEWSCONFIG appropriately.
X# Also, if you're on a BSD-derived system, you will probably need to
X# change the definition of $MAIL from "mail" to "Mail".
X#----------------------------------------------------------------------------
X#
X# Modified by Chip Salzenberg, 2 November 1992
X# Fix typo in processing of "$NEWSCTL/ignore.groups".
X#
X# Modified by Chip Salzenberg, 27 October 1992
X# Ignore messages for articles matched by "$NEWSCTL/ignore.pats".
X#
X# Modified by Chip Salzenberg, 19 October 1992
X# Ignore messages for groups named in "$NEWSCTL/ignore.groups".
X#
X# Modified by Chip Salzenberg, 21 November 1990
X# Settle "mail" vs. "Mail" with the $MAIL variable.
X#
X# Modified by Chip Salzenberg, 7 June 1990.
X# Send mail to Usenet administrator describing the rmgroup request.
X# But if group doesn't exist, don't bother.
X#
X
X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
X. ${NEWSCONFIG-/usr/lib/news/bin/config}
Xexport NEWSCTL NEWSBIN NEWSARTS
XPATH=$NEWSCTL/bin:$NEWSBIN:$NEWSPATH ; export PATH
Xumask $NEWSUMASK
X
XMAIL=mail
X
Xafile=/tmp/ncd
Xafilehdr=/tmp/ncdhdr
Xafilebody=/tmp/ncdbody
Xhdr=/tmp/nc$$
X
Xtrap "exit 1" 1 2 3 13 15
Xtrap "rm -f $hdr $afilehdr $afilebody" 0
X
X$NEWSBIN/inject/tear $afile
X$NEWSBIN/canonhdr <$afilehdr >$hdr
X
X# unapproved ctl msg? then quit
Xegrep '^Approved:' $hdr >/dev/null || exit 1
X
X# figure an egrep pattern for the group
Xpat="`echo $1 | sed 's/[+\.]/\\\\&/g'`"
X
X# quit if the group is a bone of contention
Xf=$NEWSCTL/ignore.groups
Xtest -f $f && egrep "^$pat\$" $f >/dev/null && exit 0
X
X# quit if an admin-written pattern matches
Xf=$NEWSCTL/ignore.pats
Xtest -f $f && egrep -f $f $hdr >/dev/null && exit 0
X
X# quit if the group is missing or if type is 'x' or '='
Xtype=`awk "/^$pat / { print \\$4; exit }" $NEWSCTL/active`
X
Xcase "$type" in
X""|x|=*) exit 0 ;;
Xesac
X
X# determine who sent the message
XSENDER="`grep '^Sender:' $hdr | sed 's/^[^:]*: *//'`"
Xcase "$SENDER" in
X"")	SENDER="`grep '^From:' $hdr | sed 's/^[^:]*: *//'`" ;;
Xesac
X
X( echo "$SENDER says"
X  echo "to remove the group '$1'"
X  echo "in this article:"
X  echo "================================================================"
X  cat $afilehdr $afilebody ) |
X    $MAIL -s "Remove $1" "$NEWSMASTER"
Xexit 0
END_OF_FILE
if test 2349 -ne `wc -c <'rmgroup'`; then
    echo shar: \"'rmgroup'\" unpacked with wrong size!
fi
chmod +x 'rmgroup'
# end of 'rmgroup'
fi
echo shar: End of shell archive.
exit 0
-- 
Chip Salzenberg at Teltronics/TCT  <chip@tct.com>, <73717.366@compuserve.com>
   "I am truly as big a genius as all other Rush fans." -- Bruce Bufalini
QUIT

fi
chmod +x 'rmgroup'
# end of 'rmgroup'
fi
echo shar: End of shell archive.
exit 0
-- 
Chip Salzenberg at Teltronics/TCT  <chip@tct.com>, <73717.366@compuserve.com>
   "I am truly as big a genius as all other Rush fans." -- Bruce Bufalini
Xref: sparky alt.config:6867 rec.nude:5565