#! /bin/sh

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/sbin/multipath
NAME=multipath-tools-boot
DESC="multipath"

test -x $DAEMON || exit 0

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

set -e

hsg80_init() {
	dummy_capa=2097152

	for i in $(grep -rl 2097152 /sys/block/sd*/size|awk -F/ '{print $4}')
	do
		sg_start -start /dev/$i
		sleep 1
		echo 1>/sys/block/$i/device/rescan
	done
}

case "$1" in
  start)
	echo -n "Starting $DESC "
	modprobe dm-multipath 2> /dev/null || true
	if [ -n "$(which sg_start)" ]; then hsg80_init; fi
	$DAEMON -v 0
	echo "done."
	;;
  stop)
	;;
  restart|force-reload)
	echo -n "Restarting $DESC: "
	$DAEMON -v 0
	echo "done."
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0
