tale@rpi.edu (David C Lawrence) (02/05/91)
I am posting this after seeing three requests from C News admins for this sort of thing in the past two days. It is the B News checkgroups, pseudo-configed for C News, and modified C News newgroup and rmgroup scripts. The newgroup and rmgroup scripts both mail the entire control article (so all of the headers can be examined, too) to the admin if it means changing the group to reflect the request of the message. Neither says anything at all for groups which are being blocked or refiled. The checkgroups script was simply modified to suit more what I wanted; I hate the extra lines of commands since I don't use them, and so I commented them all out. You can change them back by changing TAB-# to just TAB throughout the script; beware that the commands which are there to use inews are _not_ the right way to do it with C News. Personally, I've switched to Matthias Urlichs's perl checkgroups with a bunch of hacks. I'll be sending my changes to him soon and maybe whatever merges out of that will be appearing here again. Change the config path in all scripts, probably to /usr/lib/news/config as long as you are running standard paths. Also change the MAIL variable as appropriate in {new,rm}group. Put checkgroups in $NEWSBIN/maint and cp /bin/true to $NEWSBIN/ctl/checkgroups :-) . #! /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 checkgroups # Wrapped by usenet@usenet.rpi.edu on Mon Feb 4 02:43:41 1991 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'\" \(2584 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-/usenet/bin.server/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 2584 -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'\" \(1735 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-/usenet/bin.server/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 1735 -ne `wc -c <'rmgroup'`; then echo shar: \"'rmgroup'\" unpacked with wrong size! fi chmod +x 'rmgroup' # end of 'rmgroup' fi if test -f 'checkgroups' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'checkgroups'\" else echo shar: Extracting \"'checkgroups'\" \(3968 characters\) sed "s/^X//" >'checkgroups' <<'END_OF_FILE' X#! /bin/sh X: check active file for missing or extra newsgroups X: '@(#)checkgroups 1.25 1/15/89' X X. ${NEWSCONFIG-/usenet/bin.server/config} X Xif test ! -s $NEWSCTL/newsgroups Xthen X cp /dev/null $NEWSCTL/newsgroups Xfi Xecho "" >/tmp/$$out X# Read first line of stdin. If of the form "-n group", then only check X# for the specified group. Otherwise, assume doing standard groups Xsed -e "/^From: /w /tmp/$$out" -e '/^[a-zA-Z-]*: /d' -e '/^$/d' -e '/^[#:]/d' | ( Xread line Xcase "${line}" in X-n*) X # Doing specific group. extract group name and preserve X # all of current newsgroups file except for that group. X # Then append entries for this group. X group=`echo "x${line}" | sed -e 's/x-n /^/' -e 's/$/[. ]/'` X egrep -v "${group}" $NEWSCTL/newsgroups > /tmp/$$a X cat /tmp/$$a - > $NEWSCTL/newsgroups X ;; X*) X # Get the distributions from the checkgroups message itself X # This allows sites to append their local groups to the distributed X # checkgroups message and prevents stray checkgroups from other sites X # from showing all the local groups as being bad groups. X # X echo "${line}" > /tmp/$$msg X cat >> /tmp/$$msg X cp /dev/null /tmp/$$b X pipe='' X sed -e "s;[ ].*;;" -e "s;\..*;;" -e "s;^!;;" /tmp/$$msg | sort -u | X while read dist X do X group=`cat /tmp/$$b` X group="${group}${pipe}^$dist[. ]" X echo "${group}" > /tmp/$$b X pipe='|' X done X group=`cat /tmp/$$b` X egrep -v "${group}" $NEWSCTL/newsgroups > /tmp/$$a X cat /tmp/$$a > $NEWSCTL/newsgroups X sed -e "/^!/d" /tmp/$$msg >> $NEWSCTL/newsgroups X rm -f /tmp/$$b /tmp/$$msg X ;; Xesac X Xegrep "${group}" $NEWSCTL/active | sed 's/ .*//' | sort >/tmp/$$active Xegrep "${group}" $NEWSCTL/newsgroups | sed 's/[ ].*//' | sort >/tmp/$$newsgrps X Xcomm -13 /tmp/$$active /tmp/$$newsgrps >/tmp/$$missing Xcomm -23 /tmp/$$active /tmp/$$newsgrps >/tmp/$$remove X Xegrep "${group}" $NEWSCTL/active | sed -n "/m\$/s/ .*//p" | X sort > /tmp/$$amod.all Xegrep "${group}" $NEWSCTL/newsgroups | Xsed -n "/Moderated/s/[ ][ ]*.*//p" | sort > /tmp/$$ng.mod X Xcomm -12 /tmp/$$missing /tmp/$$ng.mod >/tmp/$$add.mod Xcomm -23 /tmp/$$missing /tmp/$$ng.mod >/tmp/$$add.unmod Xcat /tmp/$$add.mod /tmp/$$add.unmod >>/tmp/$$add X Xcomm -23 /tmp/$$amod.all /tmp/$$remove >/tmp/$$amod Xcomm -13 /tmp/$$ng.mod /tmp/$$amod >/tmp/$$ismod Xcomm -23 /tmp/$$ng.mod /tmp/$$amod >/tmp/$$nm.all Xcomm -23 /tmp/$$nm.all /tmp/$$add >/tmp/$$notmod X Xecho "" >>/tmp/$$out Xif test -s /tmp/$$remove Xthen X ( X echo "# The following newsgroups are non-standard." X sed "s/^/# /" /tmp/$$remove X echo "" X #echo "# You can remove them by executing the commands:" X #for i in `cat /tmp/$$remove` X #do X # echo " /usr/lib/news/rmgroup $i" X #done X #echo "" X ) 2>&1 >>/tmp/$$out Xfi X Xif test -s /tmp/$$add Xthen X ( X echo "# The following newsgroups were missing and should be added." X sed "s/^/# /" /tmp/$$add X echo "" X #echo "# You can do this by executing the command(s):" X #for i in `cat /tmp/$$add.unmod` X #do X # echo '/usr/lib/news/inews -C '$i' </dev/null' X #done X #for i in `cat /tmp/$$add.mod` X #do X # echo '/usr/lib/news/inews -C '$i' moderated </dev/null' X #done X #echo "" X ) 2>&1 >>/tmp/$$out Xfi X Xif test -s /tmp/$$ismod Xthen X ( X echo "# The following newsgroups are not moderated and are marked moderated." X sed "s/^/# /" /tmp/$$ismod X echo "" X #echo "# You can correct this by executing the command(s):" X #for i in `cat /tmp/$$ismod` X #do X # echo '/usr/lib/news/inews -C '$i' </dev/null' X #done X #echo "" X ) 2>&1 >>/tmp/$$out Xfi X Xif test -s /tmp/$$notmod Xthen X ( X echo "# The following newsgroups are moderated and not marked so." X sed "s/^/# /" /tmp/$$notmod X echo "" X #echo "# You can correct this by executing the command(s):" X #for i in `cat /tmp/$$notmod` X #do X # echo '/usr/lib/news/inews -C '$i' moderated </dev/null' X #done X #echo "" X ) 2>&1 >>/tmp/$$out Xfi X Xif test -s /tmp/$$out Xthen X (echo "Subject: Problems with your active file" X echo "" X cat /tmp/$$out X ) | if test $# -gt 0 X then X PATH=/bin:$PATH X mail $1 X else X cat X fi Xfi X) X Xrm -f /tmp/$$* END_OF_FILE if test 3968 -ne `wc -c <'checkgroups'`; then echo shar: \"'checkgroups'\" unpacked with wrong size! fi chmod +x 'checkgroups' # end of 'checkgroups' fi echo shar: End of shell archive. exit 0 -- (setq mail '("tale@cs.rpi.edu" "tale@ai.mit.edu" "tale@rpitsmts.bitnet"))