diff --git a/tools/crm_failcount b/tools/crm_failcount index 1554917628..273e298cfb 100755 --- a/tools/crm_failcount +++ b/tools/crm_failcount @@ -1,18 +1,24 @@ #!/bin/bash -done=0 options="" target=`uname -n` -while test "$done" = "0"; do +TEMP=`getopt -o DGQVN:v:i:l:r: --long resource-id:,node:,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;; -v|--attr-value|-i|--attr-id) options="$options $1 $2"; shift; shift;; - -Q|--quiet|-D|--delete-attr|-G|--get-value|-V|-VV|-VVV) options="$options $1"; 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;; - "") done=1;; *) 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 diff --git a/tools/crm_master b/tools/crm_master index 88aa7aa34c..26f5859f1f 100755 --- a/tools/crm_master +++ b/tools/crm_master @@ -1,19 +1,25 @@ #!/bin/bash if [ -z "$OCF_RESOURCE_INSTANCE" ]; then echo "This program should only ever be invoked from inside an OCF resource agent" echo "DO NOT INVOKE MANUALLY FROM THE COMMAND LINE" exit 1 fi -done=0 -while test "$done" = "0"; do - case "$1" in - -N|--node|-v|--attr-value|-i|--attr-id|-l|--lifetime) options="$options $1 $2"; shift; shift;; - -Q|--quiet|-D|--delete-attr|-G|--get-value|-V|-VV|-VVV) options="$options $1"; shift;; - "") done=1;; - *) echo "crm_master - A convenience wrapper for crm_attribute"; echo ""; crm_attribute -?; exit 1;; - esac +TEMP=`getopt -o DGQVN:v:i:l: --long node:,attr-value:,delete-attr,get-value,attr-id:,lifetime:,quiet \ + -n 'crm_master' -- "$@"` + +if [ $? != 0 ] ; then echo "crm_master - 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|-v|--attr-value|-i|--attr-id|-l|--lifetime) options="$options $1 $2"; shift; shift;; + -Q|--quiet|-D|--delete-attr|-G|--get-value|-V) options="$options $1"; shift;; + *) echo "crm_master - A convenience wrapper for crm_attribute"; echo ""; crm_attribute -?; exit 1;; + esac done crm_attribute -N `uname -n` -n master-$OCF_RESOURCE_INSTANCE $options diff --git a/tools/crm_standby b/tools/crm_standby index 6656c2e71b..6577515239 100755 --- a/tools/crm_standby +++ b/tools/crm_standby @@ -1,49 +1,57 @@ -#!/bin/sh +#!/bin/bash done=0 options="" target=`uname -n` lifetime=0 do_get=1 op='g' -while test "$done" = "0"; do - case "$1" in - -N|--node) target="$2"; shift; shift;; - -v|--attr-value) options="$options $1 $2"; op=u; shift; shift;; - -D|--delete-attr) options="$options $1"; op=d; shift;; - -G|--get-value) options="$options $1"; op=g; shift;; - -i|--attr-id) options="$options $1 $2"; shift; shift;; - -l|--lifetime) options="$options $1 $2"; lifetime=1; shift; shift;; - -Q|--quiet|-V|-VV|-VVV) options="$options $1"; shift;; - "") done=1;; - *) echo "crm_standby - A convenience wrapper for crm_attribute"; echo ""; crm_attribute -?; exit 1;; - esac +TEMP=`getopt -o DGQVN:v:i:l: --long node:,attr-value:,delete-attr,get-value,attr-id:,lifetime:,quiet \ + -n 'crm_standby' -- "$@"` + +if [ $? != 0 ] ; then echo "crm_standby - 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;; + -v|--attr-value) options="$options $1 $2"; op=u; shift; shift;; + -D|--delete-attr) options="$options $1"; op=d; shift;; + -G|--get-value) options="$options $1"; op=g; shift;; + -i|--attr-id) options="$options $1 $2"; shift; shift;; + -l|--lifetime) options="$options $1 $2"; lifetime=1; shift; shift;; + -Q|--quiet|-V) options="$options $1"; shift;; + --) shift ; break ;; + *) echo "crm_standby - A convenience wrapper for crm_attribute"; echo ""; crm_attribute -?; exit 1;; + esac done case $op in g) crm_attribute -N $target -n standby $cmd $options -l forever 2>&1 > /dev/null if [ $? = 0 ]; then crm_attribute -N $target -n standby $options -l forever exit 0 fi crm_attribute -N $target -n standby $cmd $options -l reboot -d off ;; u) if [ $lifetime = 0 ]; then options="$options -l forever" fi crm_attribute -N $target -n standby $options ;; d) if [ $lifetime = 0 ]; then crm_attribute -N $target -n standby $options -l forever crm_attribute -N $target -n standby $options -l reboot else crm_attribute -N $target -n standby $options fi ;; esac