From f2c4c24823608b96db875216aaa57ad795f8805b Mon Sep 17 00:00:00 2001 From: Marc Wodahl Date: Thu, 4 Jan 2024 21:26:00 -0700 Subject: [PATCH 1/2] Update do_kafka_test to assign DOCKER_HOST_IP if not set --- do_kafka_test.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/do_kafka_test.sh b/do_kafka_test.sh index 0237bbca..806179dd 100755 --- a/do_kafka_test.sh +++ b/do_kafka_test.sh @@ -22,9 +22,9 @@ PPM_IMAGE_TAG=do-kafka-test-ppm-image PPM_IMAGE_NAME=jpo-cvdp_ppm setup() { - if [ -z $DOCKER_HOST_IP ]; then - echo "DOCKER_HOST_IP is not set. Exiting." - exit 1 + 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) fi # print setup info From 7611da465fdf3220db0d0716ddcef36e6b25bca5 Mon Sep 17 00:00:00 2001 From: Marc Wodahl Date: Fri, 5 Jan 2024 09:50:20 -0700 Subject: [PATCH 2/2] update ifconfig command, add additional check if ip can't be determined --- do_kafka_test.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/do_kafka_test.sh b/do_kafka_test.sh index 806179dd..6c5c9fce 100755 --- a/do_kafka_test.sh +++ b/do_kafka_test.sh @@ -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 ==="