#!/usr/bin/bash
#
# Called by the master instance of Shaman to notify about a crashed node.
#
# Provided environment variables:
# - EVENT - name of the event (NODE_CRASHED)
# - SRC_NODE_ID - node identifier
#

. /usr/share/shaman/functions

verify_caller

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

if [ "x$EVENT" != "xNODE_CRASHED" ]; then
	exit 0
fi

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

vstorage-mpfs host ha-notify-crashed --host-id "$SRC_NODE_ID" --quiet
exit $?
