#!/bin/bash

options=""
target=`uname -n`

TEMP=`getopt -o DGQVN:U:v:i:l:r: --long resource-id:,node:,uname:,attr-value:,delete-attr,get-value,attr-id:,lifetime:,quiet \
     -n 'crm_failcount' -- "$@"`

if [ $? != 0 ] ; then echo "crm_failcount - A convenience wrapper for crm_attribute"; echo ""; crm_attribute -?; exit 1 ; fi

# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"

while true ; do
    case "$1" in
	-N|--node) target="$2"; shift; shift;;
	-U|--uname) target="$2"; shift; shift;;
	-v|--attr-value|-i|--attr-id) options="$options $1 $2"; shift; shift;;
	-Q|--quiet|-D|--delete-attr|-G|--get-value|-V) options="$options $1"; shift;;
	-r|--resource-id) options="$options -n fail-count-$2"; shift; shift;;
	--) shift ; break ;;
	*) echo "crm_failcount - A convenience wrapper for crm_attribute"; echo ""; crm_attribute -?; exit 1;;
    esac
done

crm_attribute -N $target $options -t status -d 0
