Skip to content

Commit

Permalink
Remove awk dependency in auto-setup.sh (#2068)
Browse files Browse the repository at this point in the history
* Remove awk dependency in auto-setup.sh

* Remove read dependency in auto-setup.sh

* Fix spacing
  • Loading branch information
alexshtin authored Oct 19, 2021
1 parent 92081a5 commit 077d39c
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions docker/auto-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand Down

0 comments on commit 077d39c

Please sign in to comment.