#! /bin/sh
# rmgroup group - snuff group. active file is locked at entry
# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
. ${NEWSCONFIG-/usr/lib/news/bin/config}
export NEWSCTL NEWSBIN NEWSARTS
PATH=$NEWSCTL/bin:$NEWSBIN:$NEWSPATH ; export PATH
umask $NEWSUMASK

F=/tmp/nc$$

cat >$F
grep -s '^Approved:' $F || { rm -f $F; exit 1; }	# unapproved ctl msg? then quit
SENDER="`grep '^Sender:' $F | sed 's/^[^:]*: *//'`"
case "$SENDER" in
"")
	SENDER="`grep '^From:' $F | sed 's/^[^:]*: *//'`"
	;;
esac

# remove active entry
sed "/^`echo $1 | sed 's/\./\\\\./g'` /d" $NEWSCTL/active >$F.act
cp $NEWSCTL/active $NEWSCTL/active.old
cp $F.act $NEWSCTL/active

# rm -rf $NEWSARTS/`echo $1 | tr . / `	# remove the directory
dir=$NEWSARTS/`echo $1 | tr . / `	# name the directory
export dir				# for sub-shell below
(
	if test -x $dir; then
		cd $dir				# go there
		rm -f *
		cd ..
		rmdir `basename "$dir" '' `	# remove the empty directory
	fi
)

# tell the local usenet administrator the bad news
echo "rmgrouped $1 cuz $SENDER said to" | mail $NEWSMASTER

rm -f $F*
