On Tue, Dec 28, 2010 at 02:28:54PM +0100, Alexander Krauth wrote:
> # HG changeset patch
> # User Alexander Krauth <[email protected]>
> # Date 1293542864 -3600
> # Node ID acda99851b8bcb0cca5f68de7d5dfa0d10a1ccc0
> # Parent c1f5d600c4e929ac582570c61d2e7c3d2e4030a6
> High: SAPDatabase: Fixed wrong scope of rc variable in service_start/stop
> functions
>
> diff -r c1f5d600c4e9 -r acda99851b8b heartbeat/SAPDatabase
> --- a/heartbeat/SAPDatabase Tue Dec 28 14:24:49 2010 +0100
> +++ b/heartbeat/SAPDatabase Tue Dec 28 14:27:44 2010 +0100
> @@ -178,26 +178,26 @@
> # listener_start: Start the given listener
> #
> listener_start() {
> - orasid="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
> - rc=$OCF_SUCCESS
> - output=`echo "lsnrctl start $NETSERVICENAME" | su - $orasid 2>&1`
> + local orasid="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
> + local lrc=$OCF_SUCCESS
> + local output=`echo "lsnrctl start $NETSERVICENAME" | su - $orasid 2>&1`
This won't work. You have to split it into two to preserve the
exit code:
local output
output=`echo "lsnrctl start $NETSERVICENAME" | su - $orasid 2>&1`
> if [ $? -eq 0 ]
> then
> ocf_log info "Oracle Listener $NETSERVICENAME started: $output"
> - rc=$OCF_SUCCESS
> + lrc=$OCF_SUCCESS
> else
> ocf_log err "Oracle Listener $NETSERVICENAME start failed: $output"
> - rc=$OCF_ERR_GENERIC
> + lrc=$OCF_ERR_GENERIC
> fi
> - return $rc
> + return $lrc
> }
>
> #
> # listener_stop: Stop the given listener
> #
> listener_stop() {
> - orasid="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
> - rc=$OCF_SUCCESS
> + local orasid="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
> + local lrc=$OCF_SUCCESS
> if
> listener_status
> then
> @@ -205,84 +205,86 @@
> else
> return $OCF_SUCCESS
> fi
> - output=`echo "lsnrctl stop $NETSERVICENAME" | su - $orasid 2>&1`
> + local output=`echo "lsnrctl stop $NETSERVICENAME" | su - $orasid 2>&1`
Ditto here.
> if [ $? -eq 0 ]
> then
> ocf_log info "Oracle Listener $NETSERVICENAME stopped: $output"
> else
> ocf_log err "Oracle Listener $NETSERVICENAME stop failed: $output"
> - rc=$OCF_ERR_GENERIC
> + lrc=$OCF_ERR_GENERIC
> fi
> - return $rc
> + return $lrc
> }
>
> #
> # listener_status: is the given listener running?
> #
> listener_status() {
> - orasid="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
> + local lrc=$OCF_SUCCESS
> + local orasid="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
> # Note: ps cuts off it's output at column $COLUMNS, so "ps -ef" can not be
> used here
> # as the output might be to long.
> - cnt=`ps efo args --user $orasid | grep $NETSERVICENAME | grep -c tnslsnr`
> + local cnt=`ps efo args --user $orasid | grep $NETSERVICENAME | grep -c
> tnslsnr`
> if [ $cnt -eq 1 ]
> then
> - rc=$OCF_SUCCESS
> + lrc=$OCF_SUCCESS
> else
> ocf_log info "listener process not running for $NETSERVICENAME for $SID"
> - rc=$OCF_ERR_GENERIC
> + lrc=$OCF_ERR_GENERIC
> fi
> - return $rc
> + return $lrc
> }
>
> #
> # x_server_start: Start the given x_server
> #
> x_server_start() {
> - rc=$OCF_SUCCESS
> - output=`echo "x_server start" | su - $sidadm 2>&1`
> + local rc=$OCF_SUCCESS
> + local output=`echo "x_server start" | su - $sidadm 2>&1`
Here too.
> if [ $? -eq 0 ]
> then
> ocf_log info "MaxDB x_server start: $output"
> - rc=$OCF_SUCCESS
> + lrc=$OCF_SUCCESS
> else
> ocf_log err "MaxDB x_server start failed: $output"
> - rc=$OCF_ERR_GENERIC
> + lrc=$OCF_ERR_GENERIC
> fi
> - return $rc
> + return $lrc
> }
>
> #
> # x_server_stop: Stop the x_server
> #
> x_server_stop() {
> - rc=$OCF_SUCCESS
> - output=`echo "x_server stop" | su - $sidadm 2>&1`
> + local lrc=$OCF_SUCCESS
> + local output=`echo "x_server stop" | su - $sidadm 2>&1`
And here.
> if [ $? -eq 0 ]
> then
> ocf_log info "MaxDB x_server stop: $output"
> else
> ocf_log err "MaxDB x_server stop failed: $output"
> - rc=$OCF_ERR_GENERIC
> + lrc=$OCF_ERR_GENERIC
> fi
> - return $rc
> + return $lrc
> }
>
> #
> # x_server_status: is the x_server running?
> #
> x_server_status() {
> - sdbuser=`grep "^SdbOwner" /etc/opt/sdb | awk -F'=' '{print $2}'`
> + local lrc=$OCF_SUCCESS
> + local sdbuser=`grep "^SdbOwner" /etc/opt/sdb | awk -F'=' '{print $2}'`
> # Note: ps cuts off it's output at column $COLUMNS, so "ps -ef" can not be
> used here
> # as the output might be to long.
> - cnt=`ps efo args --user $sdbuser | grep -c vserver`
> + local cnt=`ps efo args --user $sdbuser | grep -c vserver`
> if [ $cnt -ge 1 ]
> then
> - rc=$OCF_SUCCESS
> + lrc=$OCF_SUCCESS
> else
> ocf_log info "x_server process not running"
> - rc=$OCF_ERR_GENERIC
> + lrc=$OCF_ERR_GENERIC
> fi
> - return $rc
> + return $lrc
> }
>
> #
> _______________________________________________________
> Linux-HA-Dev: [email protected]
> http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> Home Page: http://linux-ha.org/
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/