diff options
Diffstat (limited to 'scripts/wsrep_sst_common.sh')
-rwxr-xr-x | scripts/wsrep_sst_common.sh | 52 |
1 files changed, 19 insertions, 33 deletions
diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index f00870c0c96..e72b74ab6d1 100755 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -20,13 +20,13 @@ set -u WSREP_SST_OPT_BYPASS=0 WSREP_SST_OPT_BINLOG="" -WSREP_SST_OPT_CONF_SUFFIX="" WSREP_SST_OPT_DATA="" WSREP_SST_OPT_AUTH=${WSREP_SST_OPT_AUTH:-} WSREP_SST_OPT_USER=${WSREP_SST_OPT_USER:-} WSREP_SST_OPT_PSWD=${WSREP_SST_OPT_PSWD:-} WSREP_SST_OPT_DEFAULT="" WSREP_SST_OPT_EXTRA_DEFAULT="" +WSREP_SST_OPT_SUFFIX_DEFAULT="" while [ $# -gt 0 ]; do case "$1" in @@ -35,19 +35,16 @@ case "$1" in # # Break address string into host:port/path parts # - if echo $WSREP_SST_OPT_ADDR | grep -qe '^\[.*\]' - then - # IPv6 notation - readonly WSREP_SST_OPT_HOST=${WSREP_SST_OPT_ADDR/\]*/\]} - readonly WSREP_SST_OPT_HOST_UNESCAPED=$(echo $WSREP_SST_OPT_HOST | \ - cut -d '[' -f 2 | cut -d ']' -f 1) - else - # "traditional" notation - readonly WSREP_SST_OPT_HOST=${WSREP_SST_OPT_ADDR%%[:/]*} - fi + readonly WSREP_SST_OPT_HOST=${WSREP_SST_OPT_ADDR%%[:/]*} + readonly WSREP_SST_OPT_HOST_UNESCAPED=`echo "$WSREP_SST_OPT_HOST"|awk '{if(match($0,/^\[.*\]$/)) $0=substr($0,2,RLENGTH-2);print}'` readonly WSREP_SST_OPT_ADDR_PORT=$(echo $WSREP_SST_OPT_ADDR | \ cut -d ']' -f 2 | cut -s -d ':' -f 2 | cut -d '/' -f 1) readonly WSREP_SST_OPT_PATH=${WSREP_SST_OPT_ADDR#*/} + readonly WSREP_SST_OPT_MODULE=${WSREP_SST_OPT_PATH%%/*} + remain=${WSREP_SST_OPT_PATH#*/} + readonly WSREP_SST_OPT_LSN=${remain%%/*} + remain=${remain#*/} + readonly WSREP_SST_OPT_SST_VER=${remain%%/*} shift ;; '--bypass') @@ -66,7 +63,7 @@ case "$1" in shift ;; '--defaults-group-suffix') - WSREP_SST_OPT_CONF_SUFFIX="$2" + readonly WSREP_SST_OPT_SUFFIX_DEFAULT="$1=$2" shift ;; '--host') @@ -122,7 +119,6 @@ shift done readonly WSREP_SST_OPT_BYPASS readonly WSREP_SST_OPT_BINLOG -readonly WSREP_SST_OPT_CONF_SUFFIX if [ -n "${WSREP_SST_OPT_ADDR:-}" ]; then if [ -n "${WSREP_SST_OPT_PORT:-}" ]; then @@ -161,19 +157,18 @@ else MY_PRINT_DEFAULTS=my_print_defaults fi -readonly WSREP_SST_OPT_CONF="$WSREP_SST_OPT_DEFAULT $WSREP_SST_OPT_EXTRA_DEFAULT" -MY_PRINT_DEFAULTS="$MY_PRINT_DEFAULTS $WSREP_SST_OPT_CONF" +readonly WSREP_SST_OPT_CONF="$WSREP_SST_OPT_DEFAULT $WSREP_SST_OPT_EXTRA_DEFAULT $WSREP_SST_OPT_SUFFIX_DEFAULT" +readonly MY_PRINT_DEFAULTS="$MY_PRINT_DEFAULTS $WSREP_SST_OPT_CONF" + wsrep_auth_not_set() { [ -z "$WSREP_SST_OPT_AUTH" -o "$WSREP_SST_OPT_AUTH" = "(null)" ] } -# For Bug:1200727 -if $MY_PRINT_DEFAULTS sst | grep -q "wsrep_sst_auth" -then - if wsrep_auth_not_set - then - WSREP_SST_OPT_AUTH=$($MY_PRINT_DEFAULTS sst | grep -- "--wsrep_sst_auth" | cut -d= -f2) +# State Snapshot Transfer authentication password was displayed in the ps output. Bug fixed #1200727. +if $MY_PRINT_DEFAULTS sst | grep -q "wsrep_sst_auth"; then + if wsrep_auth_not_set; then + WSREP_SST_OPT_AUTH=$($MY_PRINT_DEFAULTS sst | grep -- "--wsrep_sst_auth" | cut -d= -f2) fi fi readonly WSREP_SST_OPT_AUTH @@ -249,7 +244,7 @@ wsrep_check_programs() # process like encryption, etc..... # parse such configuration option. (group for xb settings is [sst] in my.cnf # -# 1st param: group : name of the config file section, e.g. mysqld +# 1st param: group (config file section like sst) or my_print_defaults argument (like --mysqld) # 2nd param: var : name of the variable in the section, e.g. server-id # 3rd param: - : default value for the param parse_cnf() @@ -258,20 +253,11 @@ parse_cnf() local var=$2 local reval="" - # print the default settings for given group using my_print_default. # normalize the variable names specified in cnf file (user can use _ or - for example log-bin or log_bin) - # then grep for needed variable + # then search for needed variable # finally get the variable value (if variables has been specified multiple time use the last value only) - # look in group+suffix - if [ -n $WSREP_SST_OPT_CONF_SUFFIX ]; then - reval=$($MY_PRINT_DEFAULTS "${group}${WSREP_SST_OPT_CONF_SUFFIX}" | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2- | tail -1) - fi - - # look in group - if [ -z $reval ]; then - reval=$($MY_PRINT_DEFAULTS $group | awk -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2- | tail -1) - fi + reval=$($MY_PRINT_DEFAULTS "${group}" | awk -v var="${var}" 'BEGIN { OFS=FS="=" } { gsub(/_/,"-",$1); if ( $1=="--"var) lastval=substr($0,length($1)+2) } END { print lastval}') # use default if we haven't found a value if [ -z $reval ]; then |