wisner@hayes.fai.alaska.edu (Bill Wisner) (08/25/90)
This is the newgroup script I use on my system to have notification of newgroup messages mailed to me instead of having them automatically executed. It is improved over the version that Chip Salzenebrg posted a few weeks ago in that it handles cases where a group is having its moderation status changed instead of being created. You may need to edit the filename in line 13 if you don't use the standard path for your C news configuration file. Bill Wisner <wisner@hayes.fai.alaska.edu> Gryphon Gang Fairbanks AK 99775 "If you have a problem with one of my users, take it to me, and if I need to kill them, I will." -- Eliot Lear <lear@turbo.bio.net> #! /bin/sh # newgroup group flag # subject to our sys file group pattern # # Modified by Chip Salzenberg, 7 June 1990. # Send mail to Usenet administrator describing the newgroup request. # But if group already exists with correct type, don't bother. # # Modified by Bill Wisner, 23 August 1990 # Properly handle changes in moderation status. # =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()= . ${NEWSCONFIG-/usr/lib/newsbin/config} export NEWSCTL NEWSBIN NEWSARTS PATH=$NEWSCTL/bin:$NEWSBIN/relay:$NEWSBIN:$NEWSPATH ; export PATH # include mkpdir umask $NEWSUMASK afile=/tmp/ncd afilehdr=/tmp/ncdhdr afilebody=/tmp/ncdbody hdr=/tmp/nc$$ trap "exit 1" 1 2 3 13 15 trap "rm -f $hdr $afile $afilehdr $afilebody; exit 0" 0 $NEWSBIN/inject/tear $afile $NEWSBIN/canonhdr <$afilehdr >$hdr # unapproved ctl msg? then quit grep -s '^Approved:' $hdr >/dev/null || { rm -f $hdr; exit 0; } # quit if the group already exists in the form requested pat="^`echo $1 | sed 's/\./\\\\./g'` " type=`awk "/$pat/ { print \\$4; exit }" $NEWSCTL/active` case "$type" in x|=*) exit 0 ;; y) test "" = "$2" && exit 0 ;; m) test "moderated" = "$2" && exit 0 ;; esac SENDER="`grep '^Sender:' $hdr | sed 's/^[^:]*: *//'`" case "$SENDER" in "") SENDER="`grep '^From:' $hdr | sed 's/^[^:]*: *//' `" ;; esac if test "$type" -eq "y" -a "moderated" = "$2"; then ( echo "$SENDER says" echo "to change the group '$1' from unmoderated to moderated" if test -s $afilebody; then echo "and adds this comment:"; cat $afilebody fi ) | mail $NEWSMASTER exit 0 fi if test "$type" -eq "m" -a "moderated" != "$2"; then ( echo "$SENDER says" echo "to change the group '$1' from moderated to unmoderated" if test -s $afilebody; then echo "and adds this comment:"; cat $afilebody fi ) | mail $NEWSMASTER exit 0 fi ( echo "$SENDER says" if test "moderated" = "$2"; then echo "to create the moderated group '$1'" else echo "to create the group '$1'" fi if test -s $afilebody; then echo "and adds this comment:"; cat $afilebody fi ) | mail $NEWSMASTER