#!/bin/sh

# Don't care about DB props so tell rsf.sh not to waste time reading them
DB_PROPS_DEFINED=true
. /opt/HAC/bin/rsf.sh

usage() {
	cat <<-EOF
	Usage: $1 <service>

	This should be used to determine the recommended action to resolve a broken service.
	The necessary action will depend on the state of any resources controlled by the service
	and may depend on the service state on another node in the cluster.

	The output from this script will either recommend a repair procedure, or give a reason why
	the service cannot be repaired, as well as giving a list of resources and their online/offline
	state.

	If adding additional start/stop scripts to allow the HA service to control custom resources,
	this script can be forced to check those additional resources by adding a C script to the rc
	directory in addition to the S and K scripts.
	The C script should exit with one of the the following codes that can be obtained by sourcing
	/opt/HAC/bin/rsf.sh:
	    RSF_CHECK_ONLINE  : All resources are online
	    RSF_CHECK_PARTIAL : Some resources are online but not all
	    RSF_CHECK_OFFLINE : All resources are offline
	    RSF_CHECK_NORESRC : The start/stop script does not control any resources
	    RSF_CHECK_ERROR   : An error occurred
	The C script can relay information about online resources, offline resources or errors, by
	outputing lines to stdout that begin with:
	    "ONLINE:"  : resource is online
	    "OFFLINE:" : resource is offline
	    "ERROR:"   : error occurred
	EOF
}

if [ $# -gt 0 ]; then
	for arg in $*; do
		if [ "$arg" = "-h" ]; then
			usage `basename $0`
			exit
		fi
	done
fi

${HAC_PYTHON} /opt/HAC/RSF-1/lib/python/rsf_cluster/Recovery.pyc $1

exit $?
