Commit e78e308e authored by Daniel Black's avatar Daniel Black

wsrep_sst_common: parse --address and split WSREP_SST_OPT_PATH

Use the string functionality of sh to split the address:

IPv6 test:
. scripts/wsrep_sst_common.sh --address [ipv6]:port/module/lsn_version/sst_ver/some_future_option1/some_future_option2
$ set | grep WSREP_SST
WSREP_SST_OPT_ADDR='[ipv6]:port/module/lsn_version/sst_ver/some_future_option1/some_future_option2'
WSREP_SST_OPT_AUTH=
WSREP_SST_OPT_BINLOG=
WSREP_SST_OPT_BYPASS=0
WSREP_SST_OPT_CONF='  '
WSREP_SST_OPT_DATA=
WSREP_SST_OPT_DEFAULT=
WSREP_SST_OPT_EXTRA_DEFAULT=
WSREP_SST_OPT_HOST='[ipv6]'
WSREP_SST_OPT_HOST_UNESCAPED=ipv6
WSREP_SST_OPT_LSN=lsn_version
WSREP_SST_OPT_MODULE=module
WSREP_SST_OPT_PATH=module/lsn_version/sst_ver/some_future_option1/some_future_option2
WSREP_SST_OPT_PORT=port
WSREP_SST_OPT_PSWD=
WSREP_SST_OPT_SST_VER=sst_ver
WSREP_SST_OPT_SUFFIX_DEFAULT=
WSREP_SST_OPT_USER=

IPv4 test:
. scripts/wsrep_sst_common.sh --address ipv4:port/module/lsn_version/sst_ver/some_future_option1/some_future_option2
$ set | grep WSREP_SST
WSREP_SST_OPT_ADDR=ipv4:port/module/lsn_version/sst_ver/some_future_option1/some_future_option2
WSREP_SST_OPT_AUTH=
WSREP_SST_OPT_BINLOG=
WSREP_SST_OPT_BYPASS=0
WSREP_SST_OPT_CONF='  '
WSREP_SST_OPT_DATA=
WSREP_SST_OPT_DEFAULT=
WSREP_SST_OPT_EXTRA_DEFAULT=
WSREP_SST_OPT_HOST=ipv4
WSREP_SST_OPT_LSN=lsn_version
WSREP_SST_OPT_MODULE=module
WSREP_SST_OPT_PATH=module/lsn_version/sst_ver/some_future_option1/some_future_option2
WSREP_SST_OPT_PORT=port
WSREP_SST_OPT_PSWD=
WSREP_SST_OPT_SST_VER=sst_ver
WSREP_SST_OPT_SUFFIX_DEFAULT=
WSREP_SST_OPT_USER=
parent 95e5fe67
......@@ -35,19 +35,20 @@ case "$1" in
#
# Break address string into host:port/path parts
#
if echo $WSREP_SST_OPT_ADDR | grep -qe '^\[.*\]'
readonly WSREP_SST_OPT_HOST=${WSREP_SST_OPT_ADDR%%[:/]*}
if [ ${WSREP_SST_OPT_HOST:0:1} = '[' ]
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%%[:/]*}
readonly WSREP_SST_OPT_HOST_UNESCAPED=${WSREP_SST_OPT_HOST:1:-1}
fi
readonly WSREP_SST_OPT_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')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment