chip@tct.uucp (Chip Salzenberg) (11/22/90)
Some time ago, I posted my versions of the C News control message scripts. My modifications had the purpose of making the only effect of newgroup/rmgroup control messages being the delivery of E-Mail to the Usenet administrator. I appreciate the efforts of Bill Wisner and David Lawrence in clarifying the output of the newgroup script when a control message requests a change in moderation status. Today I did some more cleanup (merging common code, that kind of thing) and added a very important feature: newsgroups with "+" in their name are now handled correctly. Oh, yes, and "rmgroup" control messages now produce no output if the group in question exists with a type of "x" or "=". Scripts follow. 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@tct on Wed Nov 21 18:51:08 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'\" \(2581 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, 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-/u/news/lib/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# quit if the group already exists in the form requested Xpat="^`echo $1 | sed 's/[+\.]/\\\\&/g'` " 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 2581 -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'\" \(1732 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, 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-/u/news/lib/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# quit if the group is missing or if type is 'x' or '=' Xpat="^`echo $1 | sed 's/[+\.]/\\\\&/g'` " 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 1732 -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.uucp>, <uunet!pdn!tct!chip> "I've been cranky ever since my comp.unix.wizards was removed by that evil Chip Salzenberg." -- John F. Haugh II