From 12750837a6bdd175ea2b65497f8ae722a76cff04 Mon Sep 17 00:00:00 2001 From: szaimen Date: Mon, 15 Aug 2022 13:38:24 +0200 Subject: [PATCH] wait for the database startup correctly Signed-off-by: szaimen --- Containers/nextcloud/start.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Containers/nextcloud/start.sh b/Containers/nextcloud/start.sh index 9c0fe07a..7cec862c 100644 --- a/Containers/nextcloud/start.sh +++ b/Containers/nextcloud/start.sh @@ -11,7 +11,12 @@ POSTGRES_USER="oc_$POSTGRES_USER" export POSTGRES_USER # Fix false database connection on old instances -if [ -f "/var/www/html/config/config.php" ] && sleep 2 && psql -d "postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:5432/$POSTGRES_DB" -c "select now()"; then +if [ -f "/var/www/html/config/config.php" ]; then + sleep 2 + while ! psql -d "postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:5432/$POSTGRES_DB" -c "select now()"; do + echo "Waiting for the database to start..." + sleep 5 + done sed -i "s|'dbuser'.*=>.*$|'dbuser' => '$POSTGRES_USER',|" /var/www/html/config/config.php sed -i "s|'dbpassword'.*=>.*$|'dbpassword' => '$POSTGRES_PASSWORD',|" /var/www/html/config/config.php fi