# HG changeset patch # User Alexander Krauth <li...@sap.com> # Date 1293543649 -3600 # Node ID 01b9f3a556ea2548e23e9251af592b2fb1da4f7f # Parent 73e079bc06373c5dc032ac294a344a848f304ccf High: SAPInstance: Eliminate hostname command call for default parameter of sapstartsrv
diff -r 73e079bc0637 -r 01b9f3a556ea heartbeat/SAPInstance --- a/heartbeat/SAPInstance Tue Dec 28 14:39:38 2010 +0100 +++ b/heartbeat/SAPInstance Tue Dec 28 14:40:49 2010 +0100 @@ -244,12 +244,12 @@ # optional OCF parameters, we try to guess which directories are correct if [ -z "$OCF_RESKEY_DIR_EXECUTABLE" ] then - if [ -x /usr/sap/$SID/$InstanceName/exe/sapstartsrv -a -x /usr/sap/$SID/$InstanceName/exe/sapcontrol ] + if have_binary /usr/sap/$SID/$InstanceName/exe/sapstartsrv && have_binary /usr/sap/$SID/$InstanceName/exe/sapcontrol then DIR_EXECUTABLE="/usr/sap/$SID/$InstanceName/exe" SAPSTARTSRV="/usr/sap/$SID/$InstanceName/exe/sapstartsrv" SAPCONTROL="/usr/sap/$SID/$InstanceName/exe/sapcontrol" - elif [ -x /usr/sap/$SID/SYS/exe/run/sapstartsrv -a -x /usr/sap/$SID/SYS/exe/run/sapcontrol ] + elif have_binary /usr/sap/$SID/SYS/exe/run/sapstartsrv && have_binary /usr/sap/$SID/SYS/exe/run/sapcontrol then DIR_EXECUTABLE="/usr/sap/$SID/SYS/exe/run" SAPSTARTSRV="/usr/sap/$SID/SYS/exe/run/sapstartsrv" @@ -292,16 +292,6 @@ export OCF_RESKEY_START_WAITTIME=3600 fi - if [ -z "$OCF_RESKEY_AUTOMATIC_RECOVER" ] - then - OCF_RESKEY_AUTOMATIC_RECOVER=0 - else - case "$OCF_RESKEY_AUTOMATIC_RECOVER" in - 1|true|TRUE|yes|YES) export OCF_RESKEY_AUTOMATIC_RECOVER=1;; - 0|false|FALSE|no|NO) export OCF_RESKEY_AUTOMATIC_RECOVER=0;; - esac - fi - if [ -z "$OCF_RESKEY_MONITOR_SERVICES" ] then export OCF_RESKEY_MONITOR_SERVICES="disp+work|msg_server|enserver|enrepserver|jcontrol|jstart" @@ -398,7 +388,7 @@ if [ -n "$VALUE" ] then - if [ -x "$VALUE" ] + if have_binary "$VALUE" then ocf_log info "Calling userexit ${NAME} with customer script file ${VALUE}" eval "$VALUE" >/dev/null 2>&1 @@ -466,7 +456,7 @@ startrc=0; loopcount=2 fi else - if [ $loopcount -eq 1 -a $OCF_RESKEY_AUTOMATIC_RECOVER -eq 1 ] + if [ $loopcount -eq 1 ] && ocf_is_true $OCF_RESKEY_AUTOMATIC_RECOVER then ocf_log warn "SAP Instance $SID-$InstanceName start failed: $output" ocf_log warn "Try to recover $SID-$InstanceName" @@ -553,8 +543,7 @@ if [ $rc -eq $OCF_SUCCESS ] then count=0 - LOCALHOST=`hostname` - output=`$SAPCONTROL -nr $InstanceNr -host $LOCALHOST -function GetProcessList -format script` + output=`$SAPCONTROL -nr $InstanceNr -function GetProcessList -format script` # we have to parse the output, because the returncode doesn't tell anything about the instance status for SERVNO in `echo "$output" | grep '^[0-9] ' | cut -d' ' -f1 | sort -u` @@ -573,11 +562,8 @@ then if [ $STATE -eq $OCF_NOT_RUNNING ] then - if [ "$MONLOG" != "NOLOG" ] - then - ocf_log err "SAP instance service $SERVICE is not running with status $COLOR !" - fi - rc=$STATE + [ "$MONLOG" != "NOLOG" ] && ocf_log err "SAP instance service $SERVICE is not running with status $COLOR !" + rc=$STATE fi count=1 fi @@ -783,10 +769,7 @@ *);; esac -US=`id -u -n` -US=`echo $US` -if - [ $US != root ] +if ! ocf_is_root then ocf_log err "$0 must be run as root" exit $OCF_ERR_PERM _______________________________________________________ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/