#!/bin/sh
##  $Revision: 1.14 $
##  Checkgroups control-message handler.

. /usr/lib/news/lib/innshellvars

PROG=checkgroups
##  Some shells don't pass in $* unless we explicitly pass it in here.
. ${PATHBIN}/parsecontrol "$@"

case ${ACTION} in
mail)
    export FROM PATHETC NEWSUSER ARTICLE
    (
	echo "${FROM} posted the following checkgroups message:"
	${SM} ${ARTICLE} | ${SED} -e '/^$/q' -e 's/^/    /'
	echo ''
	echo 'If you want to process it, then feed the body of the'
	echo 'message into docheckgroups while running as the'
	echo "\"${NEWSUSER}\" userid:"
	echo ''
	echo "/usr/lib/news/lib/docheckgroups '${NEWSGROUPPATS}' <<\-EOF-"
	${SM} ${ARTICLE} | ${SED} -e '1,/^$/d' 
	echo '-EOF-'
    ) | sed -e 's/^~/~~/' | ${MAILCMD} -s "checkgroups by ${FROM}" ${NEWSMASTER}
    ;;
doit)
    ${SM} ${ARTICLE} | ${SED} -e '1,/^$/d' \
	| /usr/lib/news/lib/docheckgroups '${NEWSGROUPPATS}' \
	| ${WRITELOG} ${LOGFILE} "checkgroups by ${FROM}"
    ;;
esac

exit
