#!/bin/sh
#
# ipmievd		This shell script takes care of starting and stopping ipmievd.
#
# chkconfig:	2345 80 30
# description:	ipmievd is a IPMI event daemon
#
# processname:	ipmievd
# config:
# pidfile:

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Source oident configureation.
if [ -f /etc/sysconfig/ipmievd ]; then
	. /etc/sysconfig/ipmievd
fi

[ -z "$IPMIEVD_INTERFACE" ] && IPMIEVD_INTERFACE="open"

# Check that networking is up.
if is_yes "${NETWORKING}"; then
	if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
		msg_network_down ipmievd
		exit 1
	fi
else
	exit 0
fi

RETVAL=0
# See how we were called.
case "$1" in
  start)
	# Start daemons.
	if [ ! -f /var/lock/subsys/ipmievd ]; then
		msg_starting ipmievd
		daemon ipmievd -I $IPMIEVD_INTERFACE $IPMIEVD_OPTIONS
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ipmievd
	else
		msg_already_running ipmievd
	fi
	;;
  stop)
	# Stop daemons.
	if [ -f /var/lock/subsys/ipmievd ]; then
		msg_stopping ipmievd
		killproc ipmievd
		rm -f /var/lock/subsys/ipmievd >/dev/null 2>&1
	else
		msg_not_running ipmievd
	fi
	;;
  restart|force-reload)
	$0 stop
	$0 start
	exit $?
	;;
  status)
	status ipmievd
	exit $?
	;;
#  reload)
#	msg_reloading ipmievd
#	killproc ipmievd -HUP
#	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	exit 3
esac

exit $RETVAL
