From 077d39c775d589427256f5c94e2142e21deb2d81 Mon Sep 17 00:00:00 2001 From: Alex Shtin Date: Mon, 18 Oct 2021 17:05:09 -0700 Subject: [PATCH] Remove awk dependency in auto-setup.sh (#2068) * Remove awk dependency in auto-setup.sh * Remove read dependency in auto-setup.sh * Fix spacing --- docker/auto-setup.sh | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/docker/auto-setup.sh b/docker/auto-setup.sh index 80bc9d0b3df..77160bd102a 100755 --- a/docker/auto-setup.sh +++ b/docker/auto-setup.sh @@ -98,20 +98,18 @@ wait_for_cassandra() { } wait_for_mysql() { - SERVER=$(echo "${MYSQL_SEEDS}" | awk -F ',' '{print $1}') - until nc -z "${SERVER}" "${DB_PORT}"; do + until nc -z "${MYSQL_SEEDS%%,*}" "${DB_PORT}"; do echo 'Waiting for MySQL to start up.' - sleep 1 + sleep 1 done echo 'MySQL started.' } wait_for_postgres() { - SERVER=$(echo "${POSTGRES_SEEDS}" | awk -F ',' '{print $1}') - until nc -z "${SERVER}" "${DB_PORT}"; do - echo 'Waiting for PostgreSQL to startup.' - sleep 1 + until nc -z "${POSTGRES_SEEDS%%,*}" "${DB_PORT}"; do + echo 'Waiting for PostgreSQL to startup.' + sleep 1 done echo 'PostgreSQL started.' @@ -218,10 +216,9 @@ validate_es_env() { wait_for_es() { SECONDS=0 - ES_SERVER=$(echo "${ES_SEEDS}" | awk -F ',' '{print $1}') - URL="${ES_SCHEME}://${ES_SERVER}:${ES_PORT}" + ES_SERVER="${ES_SCHEME}://${ES_SEEDS%%,*}:${ES_PORT}" - until curl --silent --fail --user "${ES_USER}":"${ES_PWD}" "${URL}" > /dev/null 2>&1; do + until curl --silent --fail --user "${ES_USER}":"${ES_PWD}" "${ES_SERVER}" > /dev/null 2>&1; do DURATION=${SECONDS} if [ "${ES_SCHEMA_SETUP_TIMEOUT_IN_SECONDS}" -gt 0 ] && [ ${DURATION} -ge "${ES_SCHEMA_SETUP_TIMEOUT_IN_SECONDS}" ]; then @@ -237,8 +234,7 @@ wait_for_es() { } setup_es_index() { - IFS=',' read -ra ES_SERVERS <<< "${ES_SEEDS}" - ES_SERVER="${ES_SCHEME}://${ES_SERVERS[0]}:${ES_PORT}" + ES_SERVER="${ES_SCHEME}://${ES_SEEDS%%,*}:${ES_PORT}" # @@@SNIPSTART setup-es-template-commands # ES_SERVER is the URL of Elasticsearch server i.e. "http://localhost:9200". SETTINGS_URL="${ES_SERVER}/_cluster/settings"