On Wed, Feb 24, 2010 at 04:16:57PM +0100, Florian Haas wrote:
> > +is_slave() {
> > + slave_info=($(mysql \
should have been a "local"...
> > + --user=$OCF_RESKEY_replication_user \
> > + --password=$OCF_RESKEY_replication_passwd \
> > + --socket=$OCF_RESKEY_socket -O connect_timeout=1 \
> > + -e 'SHOW SLAVE STATUS\G'|awk '/Running/ || /Master_[UHP]/{print
> > $2}'))
> > +
> > + if [ "$?" != 0 ]; then
And, btw, this is plain wrong.
$? is the exit code of awk, in this case.
( exit 17 ) | awk '/foo/ { print $2 }' ; echo $?
see?
> > + ocf_log err "Unable to get local slave status"
> > + return 1
> > + fi
> > +
> > + if [ -z "${slave_info[*]}" ]; then
> > + # no slave configuration, can not be slave
> > + return 1;
> > + fi
> > +
> > + if [ -z "${slave_info[3]}" ] || [ -z "${slave_info[4]}" ] || [ -z
> > "${slave_info[0]}" ] || [ -z "${slave_info[0]}" ]; then
> > + ocf_log err "Unable to get slave status"
> > + return 1
> > + fi
>
> As Dejan has already pointed out, arrays may not be available in
> non-bash shells, and it's a potential regression to rely on bash
> features in an RA that was previously Bourne shell clean. Can you come
> of with a different way of handling this?
how about
local slave_info
slave_info=$(mysql blafoo)
# No, not local slave_info=$(), because then $? is the exit code
# of declaring that variable local, which is 0 (unless your
# shell crashes half way through...)
if [ $? != 0 ] ...
# in case you need to handle mysql exit code
set -- $(echo "$slave_info" | awk '...' )
# columns now in $1, $2, ...
if [ -z "$3" ] ...
did not look at the other things yet.
--
: Lars Ellenberg
: LINBIT | Your Way to High Availability
: DRBD/HA support and consulting http://www.linbit.com
DRBD® and LINBIT® are registered trademarks of LINBIT, Austria.
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/