#! /bin/sh

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/sbin/multipathd
NAME=multipathd
DESC="multipath daemon"

test -x $DAEMON || exit 0

if [ -f /etc/default/multipath-tools ] ; then
	. /etc/default/multipath-tools
fi

set -e

case "$1" in
  start)
	echo -n "Starting $DESC"
	start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
	echo "."
	;;
  stop)
	echo -n "Stopping $DESC"
	start-stop-daemon --oknodo --stop --quiet --pidfile /var/run/$NAME.pid --exec $DAEMON
	echo "."
	;;
  reload|force-reload)
	echo "Reloading $DESC."
	start-stop-daemon --stop --signal 1 --quiet --pidfile /var/run/$NAME.pid --exec $DAEMON
	;;
  restart|force-reload)
	echo -n "Restarting $DESC"
	start-stop-daemon --oknodo --stop --quiet --pidfile /var/run/$NAME.pid --exec $DAEMON
	sleep 1
	start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
	echo "."
	;;
  *)
	N=/etc/init.d/multipath-tools
	echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	exit 1
	;;
esac

exit 0
