#!/bin/bash
#
# hppfmsvc init script.
#
# description: HP IPMI daemon provides IPMI services to clients.

# Source function library.
. /etc/rc.config

test -x /usr/hpserver/bin/hppfmsvc || exit 1

# Determine the base and follow a runlevel link name.
base=${0##*/}
link=${base#*[SK][0-9][0-9]}

# Force execution if not called by a runlevel directory.
test $link = $base && START_HPPFM="yes"
test "$START_HPPFM" = yes || exit 0

#
#	See how we were called.
#
return=$rc_done
case "$1" in
  start)
	# Check if hppfmsvc is already running
	if [ ! -f /var/lock/subsys/hppfmsvc ]; then
	    echo -n 'Starting HP Pre-failure daemon: '
	    startproc /usr/hpserver/bin/hppfmsvc || return=$rc_failed
	    [ "$return" = "$rc_done" ] && touch /var/lock/subsys/hppfmsvc
	    echo -e "$return"
	fi
	;;
  stop)
	echo -n 'Stopping HP Pre-failure daemon: '
	killproc /usr/hpserver/bin/hppfmsvc || return=$rc_failed
        [ "$return" = "$rc_done" ] && rm -f /var/lock/subsys/hppfmsvc
	echo -e "$return"
	;;
  reload|restart)
	$0 stop
	$0 start
	;;
  status)
	checkproc /usr/hpserver/bin/hppfmsvc && echo OK || echo No process
	;;
  *)
	echo "Usage: /etc/rc.d/init.d/hppfmsvc {start|stop|restart|reload|status}"
	exit 1
esac

test "$return" = "$rc_done" || exit 1
exit 0

