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

PROG=checkgroups
##  Some shells don't pass in $* unless we explicitly pass it in here.
##  =()<. @<_PATH_PARSECTL>@ "$@">()=
. /news/lib/inn/libexec/parsecontrol "$@"

case ${ACTION} in
mail)
    export FROM CONTROLPROGS NEWSUSER ARTICLE
    (
	echo "${FROM} posted the following checkgroups message:"
	ccat ${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 "${CONTROLPROGS}/docheckgroups <<\-EOF-"
	ccat ${ARTICLE} | ${SED} -e '1,/^$/d'
	echo '-EOF-'
    ) | sed -e 's/^~/~~/' | ${MAILCMD} -s "checkgroups by ${FROM}" ${NEWSMASTER}
    ;;
doit)
    ccat ${ARTICLE} | ${SED} -e '1,/^$/d' \
	| ${CONTROLPROGS}/docheckgroups \
	| ${WRITELOG} ${LOGFILE} "checkgroups by ${FROM}"
    ;;
esac

exit
