1#!/usr/local/bin/bash 2 3TEMP=`/usr/local/bin/getopt -o qDGQVN:U:v:i:l:r: --long version,help,resource:,node:,uname:,attr-value:,id:,update:,delete-attr,get-value,attr-id:,lifetime:,quiet \ 4 -n 'crm_master' -- "$@"` 5 6if [ $? != 0 ] ; then echo "crm_master - A convenience wrapper for crm_attribute"; echo ""; crm_attribute -?; exit 1 ; fi 7 8# Note the quotes around `$TEMP': they are essential! 9eval set -- "$TEMP" 10 11# Explicitly set the (usual default) lifetime, so the attribute gets set as a 12# node attribute and not a cluster property. 13options="--lifetime forever" 14 15while true ; do 16 case "$1" in 17 -N|--node|-U|--uname) options="$options $1 $2"; shift; shift;; 18 -v|--attr-value|--update|-i|--id|--attr-id|-l|--lifetime) options="$options $1 $2"; shift; shift;; 19 -Q|-q|--quiet|-D|--delete-attr|-G|--get-value|-V) options="$options $1"; shift;; 20 -r|--resource) OCF_RESOURCE_INSTANCE=$2; shift; shift;; 21 --version) crm_attribute --version; exit 0;; 22 --help) 23 echo "crm_master - A convenience wrapper for crm_attribute"; 24 echo ""; 25 echo "Set, update or delete a resource's promotion score"; 26 echo ""; 27 echo "This program should normally only be invoked from inside an OCF resource agent" 28 echo ""; 29 echo "Usage: crm_master command [options]"; 30 echo "Options:" 31 echo " --help This text" 32 echo " --version Version information" 33 echo " -V, --verbose Increase debug output" 34 echo " -q, --quiet Print only the value on stdout" 35 echo "" 36 echo "Commands:" 37 echo " -G, --query Query the current value of the attribute/option" 38 echo " -v, --update=value Update the value of the attribute/option" 39 echo " -D, --delete Delete the attribute/option" 40 echo "" 41 echo "Additional Options:" 42 echo " -N, --node=value Set an attribute for the named node (instead of the current one)." 43 echo " -l, --lifetime=value Until when should the setting take affect." 44 echo " Valid values: reboot, forever" 45 echo " -i, --id=value (Advanced) The ID used to identify the attribute" 46 exit 0;; 47 --) shift ; break ;; 48 *) echo "Unknown option: $1. See --help for details." exit 1;; 49 esac 50done 51 52if [ -z "$OCF_RESOURCE_INSTANCE" ]; then 53 echo "This program should normally only be invoked from inside an OCF resource agent" 54 echo "To set the promotion/master score from the command line, please specify a resource ID with -r" 55 exit 1 56fi 57 58crm_attribute -n master-$OCF_RESOURCE_INSTANCE $options 59