diff options
author | Mohammad Arshad <arshad@apache.org> | 2020-07-29 12:31:40 +0200 |
---|---|---|
committer | Mate Szalay-Beko <mszalay@cloudera.com> | 2022-05-17 10:09:29 +0200 |
commit | fd9219c4f5d4a0e9423cc2fd3d03c86a2edfa6d6 (patch) | |
tree | cdfed1f3db652b7d2c98a2c36c2a3b64eedb0d81 | |
parent | 161e50574baf6725dec00c547a5005f19588587d (diff) | |
download | zookeeper-fd9219c4f5d4a0e9423cc2fd3d03c86a2edfa6d6.tar.gz |
ZOOKEEPER-3876: zkServer.sh status command fails when IPV6 is configured
Modified host and IP parsing logic for IPV6
Author: Mohammad Arshad <arshad@apache.org>
Reviewers: Enrico Olivelli <eolivelli@apache.org>
Closes #1395 from arshadmohammad/ZOOKEEPER-3876
(cherry picked from commit c9f15213663fc9b86809adcbc27a4dbe1232c31a)
Signed-off-by: Enrico Olivelli <eolivelli@apache.org>
(cherry picked from commit f6b7b1b35be13a2bb35f44f58773ba87f5b40b50)
-rwxr-xr-x | bin/zkServer.sh | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/bin/zkServer.sh b/bin/zkServer.sh index 1a5056c09..816a12de5 100755 --- a/bin/zkServer.sh +++ b/bin/zkServer.sh @@ -249,7 +249,12 @@ status) echo "Client port not found in the server configs" else if [[ "$clientPortAndAddress" =~ ^.*:[0-9]+ ]] ; then - clientPortAddress=`echo "$clientPortAndAddress" | sed -e 's/:.*//'` + if [[ "$clientPortAndAddress" =~ \[.*\]:[0-9]+ ]] ; then + # Extracts address from address:port for example extracts 127::1 from "[127::1]:2181" + clientPortAddress=`echo "$clientPortAndAddress" | sed -e 's|\[||' | sed -e 's|\]:.*||'` + else + clientPortAddress=`echo "$clientPortAndAddress" | sed -e 's/:.*//'` + fi fi clientPort=`echo "$clientPortAndAddress" | sed -e 's/.*://'` fi |