#!/bin/sh

#
# $Header: /var/news/local/bin/RCS/checkinnd,v 1.5 1997/04/07 03:53:59 news Exp news $
#
# This script checks to see if the actived process is running.  If not,
# then it is started.  This should help to clean up any random actived
# crashes.  I run this program once every 5 minutes from cron.
#
# -jem@xpat.com
# John Milburn
#

# Get the INN path definitions
#### =()<. @<_PATH_SHELLVARS>@>()=
. /var/news/etc/innshellvars
#### =()<ACTIVED=@<_PATH_ACTIVED>@>()=
ACTIVED=/usr/local/news/bin/actived

## Uncomment one of following
#PSCMD="ps ax"		# Linux and BSD
#PSCMD="ps -ef"		# Solaris-2.x and SYSV

if [ "X$PSCMD" = "X" ] ;then
  exit 0
fi
#
# First, make sure the procedure works, by checking for init.
#
INITPS=X`$PSCMD | ${EGREP} " init " | ${EGREP} -v egrep |${AWK} '{print $1}'`
if [ $INITPS = "X" ] ;  then
	exit 0
fi

#
# Check ps for a running actived process.
#
ACTDPS=X`$PSCMD |  ${EGREP} actived | ${EGREP} -v grep |${AWK} '{print $1}'`
if [ ${ACTDPS} = "X" ] ;  then
	nohup $ACTIVED &
	$MAILCMD -s "ActiveD restarted by $0" $NEWSMASTER
fi

exit 0
