#!/bin/bash
# The following environment variables are provided by the caller:
# EVENT - name of the fencing event

. /usr/share/shaman/functions

verify_caller

if [ -z "$EVENT" ]; then
	echo "EVENT environment variable undefined" 1>&2
	exit 1
fi

cmd=/usr/libexec/vstorage-iscsi/vstorage-iscsid

case "$EVENT" in
	FENCE)
		$cmd fence
		exit $?
		;;
	UNFENCE)
		$cmd unfence
		exit $?
		;;
	*)
		echo "Unknown event $EVENT" 1>&2
		exit 2
		;;
esac

exit 0
