Skip to content

Commit

Permalink
update ifconfig command, add additional check if ip can't be determined
Browse files Browse the repository at this point in the history
  • Loading branch information
mwodahl committed Jan 5, 2024
1 parent f2c4c24 commit 7611da4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion do_kafka_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ PPM_IMAGE_NAME=jpo-cvdp_ppm
setup() {
if [ -z $DOCKER_HOST_IP ]
then
export DOCKER_HOST_IP=$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' | grep -v '10.*' | head -n 1)
export DOCKER_HOST_IP=$(ifconfig | grep -A 1 'inet ' | grep -v 'inet6\|127.0.0.1' | awk '{print $2}' | grep -E '^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-1]\.|^192\.168\.' | head -n 1)
fi
if [ -z $DOCKER_HOST_IP ]
then
echo "DOCKER_HOST_IP is not set and could not be determined. Exiting."
exit 1
fi


# print setup info
echo "=== Setup Info ==="
Expand Down

0 comments on commit 7611da4

Please sign in to comment.