#!@_PATH_SH@
##  $Revision: 1.16 $
##  Checkgroups control-message handler.

. @LIBDIR@/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 "@LIBDIR@/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' \
	| @LIBDIR@/docheckgroups ${NEWSGROUPPATS} \
	| ${WRITELOG} ${LOGFILE} "checkgroups by ${FROM}"
    ;;
esac

exit
