[bitnami/elasticsearch] Fix get_machine_ip to handle IPv6 addresses (#67083)

* Fix get_machine_ip to handle IPv6 addresses

Signed-off-by: Reddysekhar Gaduputi <gsekhar73@gmail.com>

* Fix get_machine_ip to handle IPv6 addresses

Signed-off-by: Reddysekhar Gaduputi <gsekhar73@gmail.com>

---------

Signed-off-by: Reddysekhar Gaduputi <gsekhar73@gmail.com>
This commit is contained in:
Reddysekhar Gaduputi 2024-05-21 21:51:53 +05:30 committed by GitHub
parent a7e3b8cbaf
commit 04f785d868
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 1 deletions

View File

@ -8,6 +8,7 @@
# Load Generic Libraries
. /opt/bitnami/scripts/liblog.sh
. /opt/bitnami/scripts/libvalidations.sh
# Functions
@ -68,7 +69,13 @@ get_machine_ip() {
error "Could not find any IP address associated to hostname ${hostname}"
exit 1
fi
echo "${ip_addresses[0]}"
# Check if the first IP address is IPv6 and add brackets
if validate_ipv6 "${ip_addresses[0]}" ; then
echo "[${ip_addresses[0]}]"
else
echo "${ip_addresses[0]}"
fi
}
########################