#!/bin/sh
#
# multipathd	Starts multipath daemon
#
# chkconfig:	345 10 90
#
# description:	The multipathd daemon is in charge of checking for failed paths.
#
# $Id: multipathd.init,v 1.5 2007/10/26 13:01:57 glen Exp $

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

[ -f /etc/sysconfig/multipathd ] && . /etc/sysconfig/multipathd

start() {
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/multipathd ]; then
		msg_starting multipathd
		modprobe dm-multipath
		daemon multipathd
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/multipathd
	else
		msg_already_running multipathd
	fi
}

stop() {
	if [ -f /var/lock/subsys/multipathd ]; then
		# Stop daemons.
		msg_stopping multipathd
		killproc --pidfile multipathd.pid multipathd -TERM
		rm -f /var/lock/subsys/multipathd
	else
		msg_not_running multipathd
	fi
}

RETVAL=0
# See how we were called.
case "$1" in
  start)
  	start
	;;

  stop)
	stop
	;;

  restart|force-reload)
	stop
	start
	;;

  status)
	status multipathd
	RETVAL=$?
	;;
  *)
	msg_usage "$0 {start|stop|status|restart|force-reload}"
	exit 3
	;;
esac

exit $RETVAL
