@@ -422,31 +422,39 @@ docker_address_match() {
422422 docker_hostname_match " $1 " || docker_ip_match " $1 " || docker_hostname_match " $resolved " || docker_ip_match " $resolved "
423423}
424424
425- # usage: wsrep_enable_new_cluster <wsrep-cluster-address> [arg [arg [...]]]
426- # ie: wsrep_enable_new_cluster gcomm://node1,node2,node3 "$@"
427- # it returns true if we need to set the --wsrep-new-cluster argument for the mysqld. Otherwise it returns false
428- wsrep_enable_new_cluster () {
429- local address=" ${WSREP_AUTO_BOOTSTRAP_ADDRESS:- $1 } " ; shift
430- local wsrepdir=" $( mysql_get_config ' wsrep-data-home-dir' " $@ " ) "
431- local wsrepaddr=" $( mysql_get_config ' wsrep-node-address' " $@ " ) "
432-
425+ # usage: wsrep_address_normalize <address>
426+ # ie: wsrep_address_normalize gcomm://172.168.2.15
427+ # it always returns <address>:<port>
428+ wsrep_address_normalize () {
433429 # it removes URI schemes like gcomm://
434- address=" ${address# [[:graph:]]*:// } "
435-
436- # it removes port suffix per address
437- address=" ${address/: [0-9]*// } "
430+ address=" ${1##*:// } "
438431
439432 # it removes options suffix ?option1=value1[&option2=value2]
440- address=" ${address% \? [[:graph:]] * } "
433+ address=" ${address%% \? * } "
441434
442435 # it replaces commas ',' with spaces ' ' and converts it to array
443436 address=(${address// ,/ } )
444437
445- # first address from list of addresses. If item doesn't exist, returns an empty string
438+ # first address from list of addresses. If item doesn't exist, returns empty string
446439 address=" ${address[0]:- } "
447440
448- # it removes port suffix
449- wsrepaddr=" ${wsrepaddr%: [0-9]* } "
441+ case " $address " in
442+ * :* | " " )
443+ ;;
444+ * )
445+ address=" ${address} :4567" ;;
446+ esac
447+
448+ echo " $address "
449+ }
450+
451+ # usage: wsrep_enable_new_cluster <wsrep-cluster-address> [arg [arg [...]]]
452+ # ie: wsrep_enable_new_cluster gcomm://node1,node2,node3 "$@"
453+ # it returns true if we need to set the --wsrep-new-cluster argument for the mysqld. Otherwise it returns false
454+ wsrep_enable_new_cluster () {
455+ local address=" $( wsrep_address_normalize " ${WSREP_AUTO_BOOTSTRAP_ADDRESS:- $1 } " ) " ; shift
456+ local wsrepdir=" $( mysql_get_config ' wsrep-data-home-dir' " $@ " ) "
457+ local wsrepaddr=" $( wsrep_address_normalize " $( mysql_get_config ' wsrep-node-address' " $@ " ) " ) "
450458
451459 if [ -z " $address " ] || [ -n " $WSREP_SKIP_AUTO_BOOTSTRAP " ] || [ -s " $wsrepdir /gvwstate.dat" ]; then
452460 return 1
@@ -455,7 +463,7 @@ wsrep_enable_new_cluster() {
455463 if [ -n " $wsrepaddr " ]; then
456464 [ " $wsrepaddr " = " $address " ]
457465 else
458- docker_address_match " $address "
466+ docker_address_match " ${ address%%:* } "
459467 fi
460468}
461469
0 commit comments