Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLOUD-4046 Deploy on dual-stack ocp4.8 fails. Now /bin/sh version
Browse files Browse the repository at this point in the history
hdaems committed Dec 1, 2021
1 parent e787715 commit ae345d1
Showing 1 changed file with 1 addition and 23 deletions.
Original file line number Diff line number Diff line change
@@ -121,29 +121,7 @@ function splitAttributesStringIntoLines() {
# The host could have 1 or more ipv4 and/or ipv6 addresses
# For this function we need to return a single ipv4 address
#
# mapfile is a Bash builtin function
# MAPFILE is the default variable name used by Bash when using the builtin function mapfile. https://www.geeksforgeeks.org/mapfile-command-in-linux-with-examples/
#
# To not be dependend on external tooling like python, the /proc directory holds information about
# the available IP addresses 'cat /proc/net/fib_tree'.
# Having access to all available IP addresses a filter has to be applied.
# Therefor awk with a block-pattern is used , see https://unix.stackexchange.com/questions/365225/how-to-get-the-ipv4-address-for-an-interface-from-proc
#
# The awk filtered output based on information retrieved from /proc/net/fib_tree is put in the
# variable MAPFILE as an indexed array via the function mapfile.
#
# The filtered output is sorted so that IPv4 address is the first in the array (MAPFILE[0]).
#
# As an addition, a message is logged when there are multiple ipv4 addresses with remediation.
#
function get_host_ipv4() {
mapfile < <(awk '/32 host/ { print f } {f=$2}' <<< "$(</proc/net/fib_trie)" | sort -n | uniq | grep -v '127.0.0.')

if [[ "${#MAPFILE[*]}" != "1" ]]
then
echo "WARNING: get_host_ipv4() returned ${#MAPFILE[*]} ipv4 addresses, only the first ${MAPFILE[0]} will be used. To override this value, please set JBOSS_HA_IP."
fi

echo "${MAPFILE[0]}"
echo $(ping -4 -c1 $(hostname) | grep PING | awk '{print $3}' | tr -d '(' | tr -d ')')
}

0 comments on commit ae345d1

Please sign in to comment.