#!/bin/sh
#
# multipath discovery

PREREQ="udev iscsi"

prereqs() { echo "$PREREQ"; }

case $1 in
prereqs)
	prereqs
	exit 0
	;;
esac

. /scripts/functions

verbose()
{
  case "$quiet" in y*|Y*|1|t*|T*)
    return 1;;
  *)
    return 0;;
  esac
}

maybe_break pre-multipath
VERBOSITY=0
MP_MODULES="dm-multipath dm-emc"

if [ ! -e /sbin/multipathd ]; then
	exit 0
fi

verbose && log_begin_msg "Loading multipath modules"
for module in ${MP_MODULES}; do
  if modprobe --syslog "$module"; then
    verbose && log_success_msg "loaded module ${module}."
  else
    log_failure_msg "failed to load module ${module}."
  fi
done
verbose && log_end_msg

# Start multipathd
verbose && log_begin_msg "Starting multipathd"
/sbin/multipathd -B

if [ -x /sbin/udevadm ]; then
    /sbin/udevadm settle
fi

maybe_break post-multipath

exit 0

