[news.software.b] Yet another newgroup/rmgroup for C News

chip@tct.uucp (Chip Salzenberg) (06/06/90)

Several people have posted newgroup/rmgroup scripts
for C News.  But I'm posting mine anyway because
they include one useful feature that I haven't seen
from the others: they only send mail to the Usenet
admin if a new group doesn't already exist in the
same form as that requested in the newgroup message
(moderated/not).

I've installed these scripts in /usr/lib/news/bin
and everything is cool.  Biff won't strike here.

Note that these scripts are based on those posted a
few days ago by Scott Hazen Mueller.

PS:  If your "mail" command doesn't support the "-s"
switch, you'll need to change the last line of each
script appropriately for your mail system.

#! /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@tct on Tue Jun  5 15:21:19 1990
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'\" \(1301 characters\)
sed "s/^X//" >'newgroup' <<'END_OF_FILE'
X#! /bin/sh
X# newgroup group flag - create group (4-field version: B-2.10.3+ compatible)
X#	subject to our sys file group pattern
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
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 $afile $afilehdr $afilebody; exit 0" 0
X
X$NEWSBIN/inject/tear $afile
X$NEWSBIN/canonhdr <$afilehdr >$hdr
X
X# unapproved ctl msg? then quit
Xgrep -s '^Approved:' $hdr >/dev/null || { rm -f $hdr; exit 0; }
X
X# quit if the group already exists in the form requested
Xpat="^`echo $1 | sed 's/\./\\\\./g'` "
Xcase `awk "/$pat/ { print \\$4; exit }" $NEWSCTL/active` in
Xx|=*)	exit 0 ;;
Xy)	test "" = "$2" && exit 0 ;;
Xm)	test "moderated" = "$2" && exit 0 ;;
Xesac
X
XSENDER="`grep '^Sender:' $hdr | sed 's/^[^:]*: *//'`"
Xcase "$SENDER" in
X"")	SENDER="`grep '^From:' $hdr | sed 's/^[^:]*: *//' `" ;;
Xesac
X
X# tell the local usenet administrator to do it by hand
Xcase "$2" in
X"")	G="$1" ;;
X*)	G="$1 $2" ;;
Xesac
X( echo "$SENDER says"
X  echo "to create the group '$G',"
X  echo "and adds this comment:";
X  cat $afilebody ) |
X    mail -s "newgroup $G" $NEWSMASTER
END_OF_FILE
if test 1301 -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'\" \(996 characters\)
sed "s/^X//" >'rmgroup' <<'END_OF_FILE'
X#! /bin/sh
X# rmgroup group - snuff group
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
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 $afile $afilehdr $afilebody; exit 0" 0
X
X$NEWSBIN/inject/tear $afile
X$NEWSBIN/canonhdr <$afilehdr >$hdr
X
X# unapproved ctl msg? then quit
Xegrep '^Approved:' $hdr >/dev/null || { rm -f $afile*; exit 0; }
X
X# quit if no active entry
Xegrep "^`echo $1 | sed 's/\./\\\\./g'` " $NEWSCTL/active >/dev/null || exit 0
X
XSENDER="`grep '^Sender:' $hdr | sed 's/^[^:]*: *//'`"
Xcase "$SENDER" in
X"")	SENDER="`grep '^From:' $hdr | sed 's/^[^:]*: *//'`" ;;
Xesac
X
X# tell the local usenet administrator to do it by hand
XG="$1"
X( echo "$SENDER says"
X  echo "to remove the group '$G',"
X  echo "and adds this comment:";
X  cat $afilebody ) |
X    mail -s "rmgroup $G" $NEWSMASTER
END_OF_FILE
if test 996 -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, the new t.b answer man      <chip@tct.uucp>, <uunet!ateng!tct!chip>