#!/sbin/sh

#ident /etc/init.d/failover: $Revision: 1.2 $
#
# Process failover configuration table.
# Called by /etc/init.d/xlv.
#

assemble=false
doit=false

cd /

case $1 in
	init)
		keep=-k
		assemble=false
		doit=true
	;;
	stop)
		doit=false
	;;
	""|start)
		keep=-k
		assemble=true
		doit=true
	;;
esac

if [ '(' -x /sbin/xlv_assemble -o -x /sbin/xvm ')' -a "$doit" = "true" ] ; then
	if [ -f /etc/failover.conf ] ; then
		if [ -x /sbin/foconfig ] ; then
			if /sbin/chkconfig verbose ; then
				echo "Configuring Failover."
			fi
			/sbin/suattr -C CAP_DEVICE_MGT+ip -c "/sbin/foconfig \
						$keep -f /etc/failover.conf"
		fi
	fi
	if [ "$assemble" = "true" ] ; then
		if [ -x /sbin/xlv_assemble ] ; then
			if /sbin/chkconfig verbose ; then
				echo "Calling xlv_assemble."
			fi
			/sbin/suattr -C CAP_DEVICE_MGT+ip -c "/sbin/xlv_assemble \
					1> /dev/null 2> /dev/null"
		fi
	fi
fi
