From 347b94dee23b8d5866e25b3ab103ed85218e9e95 Mon Sep 17 00:00:00 2001 From: "Chinmay D. Pai" Date: Thu, 20 Feb 2020 12:33:52 +0530 Subject: [PATCH] chore: fixes to shell scripts * envsubst: expression may fail to expand in single quotes * use (()) instead of let * use find instead of ls to better hand alphanumeric folders Signed-off-by: Chinmay D. Pai --- build/erpnext-assets/docker-entrypoint.sh | 2 +- build/erpnext-worker/docker-entrypoint.sh | 8 ++++---- build/frappe-assets/docker-entrypoint.sh | 2 +- build/frappe-worker/docker-entrypoint.sh | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/build/erpnext-assets/docker-entrypoint.sh b/build/erpnext-assets/docker-entrypoint.sh index 80fbf003..90bdf4b2 100755 --- a/build/erpnext-assets/docker-entrypoint.sh +++ b/build/erpnext-assets/docker-entrypoint.sh @@ -29,7 +29,7 @@ if [[ -z "$FRAPPE_SOCKETIO_PORT" ]]; then export FRAPPE_SOCKETIO_PORT=9000 fi -envsubst '${API_HOST} ${API_PORT} ${ERPNEXT_PY} ${ERPNEXT_PY_PORT} ${FRAPPE_SOCKETIO} ${FRAPPE_SOCKETIO_PORT}' \ +envsubst "${API_HOST} ${API_PORT} ${ERPNEXT_PY} ${ERPNEXT_PY_PORT} ${FRAPPE_SOCKETIO} ${FRAPPE_SOCKETIO_PORT}" \ < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf exec "$@" diff --git a/build/erpnext-worker/docker-entrypoint.sh b/build/erpnext-worker/docker-entrypoint.sh index fef4eda9..b6fc0d35 100755 --- a/build/erpnext-worker/docker-entrypoint.sh +++ b/build/erpnext-worker/docker-entrypoint.sh @@ -28,11 +28,11 @@ function configureEnv() { exit 1 fi - envsubst '${MARIADB_HOST} + envsubst "${MARIADB_HOST} ${REDIS_CACHE} ${REDIS_QUEUE} ${REDIS_SOCKETIO} - ${SOCKETIO_PORT}' < /opt/frappe/common_site_config.json.template > /home/frappe/frappe-bench/sites/common_site_config.json + ${SOCKETIO_PORT}" < /opt/frappe/common_site_config.json.template > /home/frappe/frappe-bench/sites/common_site_config.json fi } @@ -45,7 +45,7 @@ function checkConfigExists() { COUNTER=0 while [[ ! -e /home/frappe/frappe-bench/sites/common_site_config.json ]] && [[ $COUNTER -le 30 ]] ; do sleep 1 - let COUNTER=COUNTER+1 + (( COUNTER=COUNTER+1 )) echo "config file not created, retry $COUNTER" done @@ -56,7 +56,7 @@ function checkConfigExists() { } if [[ ! -e /home/frappe/frappe-bench/sites/apps.txt ]]; then - ls -1 /home/frappe/frappe-bench/apps | sort -r > /home/frappe/frappe-bench/sites/apps.txt + find /home/frappe/frappe-bench/apps -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort -r > /home/frappe/frappe-bench/sites/apps.txt fi if [ "$1" = 'start' ]; then diff --git a/build/frappe-assets/docker-entrypoint.sh b/build/frappe-assets/docker-entrypoint.sh index 3cae6744..4b791d10 100755 --- a/build/frappe-assets/docker-entrypoint.sh +++ b/build/frappe-assets/docker-entrypoint.sh @@ -29,7 +29,7 @@ if [[ -z "$FRAPPE_SOCKETIO_PORT" ]]; then export FRAPPE_SOCKETIO_PORT=9000 fi -envsubst '${API_HOST} ${API_PORT} ${FRAPPE_PY} ${FRAPPE_PY_PORT} ${FRAPPE_SOCKETIO} ${FRAPPE_SOCKETIO_PORT}' \ +envsubst "${API_HOST} ${API_PORT} ${FRAPPE_PY} ${FRAPPE_PY_PORT} ${FRAPPE_SOCKETIO} ${FRAPPE_SOCKETIO_PORT}" \ < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf exec "$@" diff --git a/build/frappe-worker/docker-entrypoint.sh b/build/frappe-worker/docker-entrypoint.sh index d5b65abf..da1934b6 100755 --- a/build/frappe-worker/docker-entrypoint.sh +++ b/build/frappe-worker/docker-entrypoint.sh @@ -28,11 +28,11 @@ function configureEnv() { exit 1 fi - envsubst '${MARIADB_HOST} + envsubst "${MARIADB_HOST} ${REDIS_CACHE} ${REDIS_QUEUE} ${REDIS_SOCKETIO} - ${SOCKETIO_PORT}' < /opt/frappe/common_site_config.json.template > /home/frappe/frappe-bench/sites/common_site_config.json + ${SOCKETIO_PORT}" < /opt/frappe/common_site_config.json.template > /home/frappe/frappe-bench/sites/common_site_config.json fi } @@ -45,7 +45,7 @@ function checkConfigExists() { COUNTER=0 while [[ ! -e /home/frappe/frappe-bench/sites/common_site_config.json ]] && [[ $COUNTER -le 30 ]] ; do sleep 1 - let COUNTER=COUNTER+1 + (( COUNTER=COUNTER+1 )) echo "config file not created, retry $COUNTER" done @@ -56,7 +56,7 @@ function checkConfigExists() { } if [[ ! -e /home/frappe/frappe-bench/sites/apps.txt ]]; then - ls -1 /home/frappe/frappe-bench/apps | sort -r > /home/frappe/frappe-bench/sites/apps.txt + find /home/frappe/frappe-bench/apps -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort -r > /home/frappe/frappe-bench/sites/apps.txt fi if [ "$1" = 'start' ]; then