#!/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
#
# 1997/12/14 Solaris compatibility included by sysuh@kigam.re.kr

# Get the INN path definitions
#### =()<. @<_PATH_SHELLVARS>@>()=
. /usr/local/news/lib/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
  if ( (ps ax >/dev/null 2>&1) ) then
    PSCMD="ps ax"
  else
    PSCMD="ps -ef"
  fi
fi
#
# First, make sure the procedure works, by checking for init.
# Linux: " init "
# Solaris: "/etc/init
#
INITPS=X`$PSCMD | ${EGREP} " init |/etc/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 & >/dev/null
	$MAILCMD -s "ActiveD restarted by $0" $NEWSMASTER </dev/null
fi

exit 0
