#!/bin/ksh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# tcpip720 src/tcpip/usr/samples/heartbeat_mon/start_heartbeat_mon.sh 1.1 
#  
# Licensed Materials - Property of IBM 
#  
# Restricted Materials of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2008 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 
#
# This script adds an entry in inittab file to start heartbeat_mon
# when OS boots. The script also starts heartbeat_mon. Hence, the
# partition reboot is not required.
#
# This script should be run after the configuration file is configured
# with the VIOS IP address. 
# 
# inittab identifier: heartbeat_mon
# runlevel: 2
# frequency: once only when OS boots
# executable to run: /usr/sbin/heartbeat_mon

mkitab "heartbeat_mon:2:once:/usr/sbin/heartbeat_mon > /dev/null  # Start heartbeat monitor daemon" 2> /dev/null

LANG=C pid=`ps -e | grep heartbeat_mon | sed -e 's/^  *//' -e 's/ .*//' &&[ ! -z "$pid" ]`

# start the hearbeat_mon deamon
if [[ -z $pid ]]; then
    /usr/sbin/heartbeat_mon
fi