From 1eb1d3863f982d5df7c29f82ca533fc79d7a8609 Mon Sep 17 00:00:00 2001 From: MoustaphaCamara Date: Fri, 6 Dec 2024 17:32:24 +0100 Subject: [PATCH 1/3] bug/minor: MySql: fix healthcheck crash --- elabctl.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/elabctl.sh b/elabctl.sh index fe17de0..b926965 100755 --- a/elabctl.sh +++ b/elabctl.sh @@ -558,7 +558,22 @@ function update-db-schema # wait for mysql container to start, but only if there is one if [ "$(docker ps | grep ${ELAB_MYSQL_CONTAINER_NAME})" ]; then echo -n "Waiting for the MySQL container to be ready before running update..." - while [ "$(docker inspect -f {{.State.Health.Status}} ${ELAB_MYSQL_CONTAINER_NAME})" != "healthy" ]; do echo -n .; sleep 2; done; echo + while true; do + # check if healthcheck is available or else will crash (e.g with older versions of elabFTW config files) + health_status=$(docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{else}}no-healthcheck{{end}}' ${ELAB_MYSQL_CONTAINER_NAME}) + if [ "$health_status" == "healthy" ]; then + echo + break + fi + if [ "$health_status" == "no-healthcheck" ]; then + echo -e "\nNo healthcheck found. Waiting for 20 seconds as fallback..." + sleep 20 + break + fi + # wait and retry while showing user activity + echo -n . + sleep 2 + done fi echo "Running command 'bin/console db:update' in the eLabFTW container now" docker exec -it "${ELAB_WEB_CONTAINER_NAME}" bin/console db:update From 4c6a28f848bd7e5e72ec171cdec20ea47f49c421 Mon Sep 17 00:00:00 2001 From: MoustaphaCamara Date: Tue, 10 Dec 2024 10:37:12 +0100 Subject: [PATCH 2/3] useless echo --- elabctl.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/elabctl.sh b/elabctl.sh index b926965..45f4b18 100755 --- a/elabctl.sh +++ b/elabctl.sh @@ -562,7 +562,6 @@ function update-db-schema # check if healthcheck is available or else will crash (e.g with older versions of elabFTW config files) health_status=$(docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{else}}no-healthcheck{{end}}' ${ELAB_MYSQL_CONTAINER_NAME}) if [ "$health_status" == "healthy" ]; then - echo break fi if [ "$health_status" == "no-healthcheck" ]; then From cdd0ec12bc4958da2d9e308d71551471ec4030b4 Mon Sep 17 00:00:00 2001 From: MoustaphaCamara Date: Thu, 12 Dec 2024 11:37:10 +0100 Subject: [PATCH 3/3] shellcheck --- elabctl.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/elabctl.sh b/elabctl.sh index 45f4b18..d3ee8fd 100755 --- a/elabctl.sh +++ b/elabctl.sh @@ -556,11 +556,11 @@ function update-db-schema { is-installed # wait for mysql container to start, but only if there is one - if [ "$(docker ps | grep ${ELAB_MYSQL_CONTAINER_NAME})" ]; then + if docker ps | grep -q "${ELAB_MYSQL_CONTAINER_NAME}"; then echo -n "Waiting for the MySQL container to be ready before running update..." while true; do - # check if healthcheck is available or else will crash (e.g with older versions of elabFTW config files) - health_status=$(docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{else}}no-healthcheck{{end}}' ${ELAB_MYSQL_CONTAINER_NAME}) + # check if healthcheck is available or else will crash (e.g. with older versions of elabFTW config files) + health_status=$(docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{else}}no-healthcheck{{end}}' "${ELAB_MYSQL_CONTAINER_NAME}") if [ "$health_status" == "healthy" ]; then break fi