From ee6a920bd1f277cf575c725c7f81dae973282ce3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phan=20Sainl=C3=A9ger?= Date: Mon, 25 Nov 2024 16:10:52 +0100 Subject: [PATCH] fix: move service postgres check before the other checks --- upgrade.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/upgrade.sh b/upgrade.sh index 4443d29..7565f64 100755 --- a/upgrade.sh +++ b/upgrade.sh @@ -50,6 +50,14 @@ echo "Postgres service name .... $POSTGRES_SERVICE_NAME" echo " ==== CHECKS ALL NEEDED COMPONANTS ARE AVAILABLE ====" +# Check POSTGRES container is running +if ! docker ps | grep -q "$POSTGRES_SERVICE_NAME"; then + printf "Docker container %s is not running.\n" "$POSTGRES_SERVICE_NAME" >&2 + return 1 +else + echo "UPGRADE: container $POSTGRES_SERVICE_NAME running." +fi + # Check origin database is in the local postgres DB_EXISTS=$(docker exec -it -u 70 $POSTGRES_SERVICE_NAME psql -tc "SELECT 1 FROM pg_database WHERE datname = '$ORIGIN_DB_NAME'" | tr -d '[:space:]') if [ "$DB_EXISTS" ]; then @@ -77,13 +85,7 @@ else exit 1 fi -# Check POSTGRES container is running -if ! docker ps | grep -q "$POSTGRES_SERVICE_NAME"; then - printf "Docker container %s is not running.\n" "$POSTGRES_SERVICE_NAME" >&2 - return 1 -else - echo "UPGRADE: container $POSTGRES_SERVICE_NAME running." -fi + ############################ # COPY ORIGINAL COMPONANTS #