[news.software.b] how to *really* get manual newgroup notification in C news

wisner@hayes.fai.alaska.edu (Bill Wisner) (08/27/90)

OK, so I blew it. My newgroup hackery was committed while under the
influence of sleep deprivation, and I made a couple of stupid little
mistakes. Blah. Here's the right version. (Thanks, tale.)

Bill Wisner <wisner@hayes.fai.alaska.edu> Gryphon Gang Fairbanks AK 99775
"Remember, some net.personalities are basically insane."
-- Karl Lehenbauer <karl@sugar.hackercorp.com>

#! /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.
#
# Modified by David C Lawrence, 25 August 1990
# Include whole article.  Fixed testing for change of status.
#
# Be sure to modify the pathname in line 20 to fit your site's configuration.
# Also, if you're not on a BSD-derived system, you will probably need to
# replace the "Mail" commands on lines 59, 68 and 80.

# =()<. ${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" = "y" -a "moderated" = "$2"; then
	( echo "$SENDER says"
	  echo "to change the group '$1' from unmoderated to moderated"
	  echo "in this article:"
	  echo
	  cat $afile ) | Mail -s "Make $1 moderated" $NEWSMASTER
	exit 0
fi

if test "$type" = "m" -a "moderated" != "$2"; then
	( echo "$SENDER says"
	  echo "to change the group '$1' from moderated to unmoderated"
	  echo "in this article:"
	  echo
 	  cat $afile ) | Mail -s "Make $1 unmoderated" $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
  echo "in this article:"
  echo
  cat $afile ) | Mail -s "Make $1 $2" $NEWSMASTER
exit 0

tale@turing.cs.rpi.edu (David C Lawrence) (08/27/90)

In <1990Aug26.203720.2157@hayes.fai.alaska.edu> wisner@hayes.fai.alaska.edu
(Bill Wisner):

   OK, so I blew it. My newgroup hackery was committed while under the
   influence of sleep deprivation, and I made a couple of stupid little
   mistakes. Blah. Here's the right version. (Thanks, tale.)

Mea culpa, but I blew it too.  $afile is never created, it is just the
prefix used for tear.  I still had to change these lines:

             cat $afile ) | Mail -s "Make $1 moderated" $NEWSMASTER

             cat $afile ) | Mail -s "Make $1 unmoderated" $NEWSMASTER

     cat $afile ) | Mail -s "Make $1 $2" $NEWSMASTER

from "$afile" to "$afilehdr $afilebody".  Note two other things:

1) I personally prefer to have the whole article there so I can look
at different things in the headers; that's why I changed it long ago
from the default.

2) I use "Mail" rather than "mail" because on my Sun3 server with a
path of /bin:/usr/bin:/usr/ucb the latter does not have a -s switch
for setting the subject and the former does.

Oh, and maybe a third thing.  The last subject might be better as
"Create $1 $2".

Sorry, w.  I should have sent you an update when I noticed my error.
--
   (setq mail '("tale@cs.rpi.edu" "tale@ai.mit.edu" "tale@rpitsmts.bitnet"))
 The most remarkable thing about looking at a picture of myself was the sudden
   realisation that my hair is in fact parted on the left and not the right.