From 50cefd5557e08031e5835294d228ffea3a59dcf8 Mon Sep 17 00:00:00 2001 From: Josh Richards Date: Wed, 22 May 2024 18:16:13 -0400 Subject: [PATCH] fix(entrypoint): Delay on auto-install to avoid error before retry Signed-off-by: Josh Richards --- 27/apache/entrypoint.sh | 11 ++++++++--- 27/fpm-alpine/entrypoint.sh | 11 ++++++++--- 27/fpm/entrypoint.sh | 11 ++++++++--- 28/apache/entrypoint.sh | 11 ++++++++--- 28/fpm-alpine/entrypoint.sh | 11 ++++++++--- 28/fpm/entrypoint.sh | 11 ++++++++--- 29/apache/entrypoint.sh | 11 ++++++++--- 29/fpm-alpine/entrypoint.sh | 11 ++++++++--- 29/fpm/entrypoint.sh | 11 ++++++++--- docker-entrypoint.sh | 11 ++++++++--- 10 files changed, 80 insertions(+), 30 deletions(-) diff --git a/27/apache/entrypoint.sh b/27/apache/entrypoint.sh index 5b627f076..70ebc709f 100755 --- a/27/apache/entrypoint.sh +++ b/27/apache/entrypoint.sh @@ -202,6 +202,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP file_env POSTGRES_USER install=false + db_wait='1s' if [ -n "${SQLITE_DATABASE+x}" ]; then echo "Installing with SQLite database" # shellcheck disable=SC2016 @@ -212,27 +213,31 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP # shellcheck disable=SC2016 install_options=$install_options' --database mysql --database-name "$MYSQL_DATABASE" --database-user "$MYSQL_USER" --database-pass "$MYSQL_PASSWORD" --database-host "$MYSQL_HOST"' install=true + db_wait='10s' elif [ -n "${POSTGRES_DB+x}" ] && [ -n "${POSTGRES_USER+x}" ] && [ -n "${POSTGRES_PASSWORD+x}" ] && [ -n "${POSTGRES_HOST+x}" ]; then echo "Installing with PostgreSQL database" # shellcheck disable=SC2016 install_options=$install_options' --database pgsql --database-name "$POSTGRES_DB" --database-user "$POSTGRES_USER" --database-pass "$POSTGRES_PASSWORD" --database-host "$POSTGRES_HOST"' install=true + db_wait='10s' fi if [ "$install" = true ]; then run_path pre-installation - echo "Starting nextcloud installation" + echo "Starting Nextcloud installation" max_retries=10 try=0 + echo "Waiting ($db_wait) for initialization of database to complete (NOTE: if this fails the first time we'll retry again in 10s)..." + sleep $db_wait until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] do - echo "Retrying install..." + echo "Retrying installation..." try=$((try+1)) sleep 10s done if [ "$try" -gt "$max_retries" ]; then - echo "Installing of nextcloud failed!" + echo "Installation of Nextcloud failed!" exit 1 fi if [ -n "${NEXTCLOUD_TRUSTED_DOMAINS+x}" ]; then diff --git a/27/fpm-alpine/entrypoint.sh b/27/fpm-alpine/entrypoint.sh index 5b627f076..70ebc709f 100755 --- a/27/fpm-alpine/entrypoint.sh +++ b/27/fpm-alpine/entrypoint.sh @@ -202,6 +202,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP file_env POSTGRES_USER install=false + db_wait='1s' if [ -n "${SQLITE_DATABASE+x}" ]; then echo "Installing with SQLite database" # shellcheck disable=SC2016 @@ -212,27 +213,31 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP # shellcheck disable=SC2016 install_options=$install_options' --database mysql --database-name "$MYSQL_DATABASE" --database-user "$MYSQL_USER" --database-pass "$MYSQL_PASSWORD" --database-host "$MYSQL_HOST"' install=true + db_wait='10s' elif [ -n "${POSTGRES_DB+x}" ] && [ -n "${POSTGRES_USER+x}" ] && [ -n "${POSTGRES_PASSWORD+x}" ] && [ -n "${POSTGRES_HOST+x}" ]; then echo "Installing with PostgreSQL database" # shellcheck disable=SC2016 install_options=$install_options' --database pgsql --database-name "$POSTGRES_DB" --database-user "$POSTGRES_USER" --database-pass "$POSTGRES_PASSWORD" --database-host "$POSTGRES_HOST"' install=true + db_wait='10s' fi if [ "$install" = true ]; then run_path pre-installation - echo "Starting nextcloud installation" + echo "Starting Nextcloud installation" max_retries=10 try=0 + echo "Waiting ($db_wait) for initialization of database to complete (NOTE: if this fails the first time we'll retry again in 10s)..." + sleep $db_wait until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] do - echo "Retrying install..." + echo "Retrying installation..." try=$((try+1)) sleep 10s done if [ "$try" -gt "$max_retries" ]; then - echo "Installing of nextcloud failed!" + echo "Installation of Nextcloud failed!" exit 1 fi if [ -n "${NEXTCLOUD_TRUSTED_DOMAINS+x}" ]; then diff --git a/27/fpm/entrypoint.sh b/27/fpm/entrypoint.sh index 5b627f076..70ebc709f 100755 --- a/27/fpm/entrypoint.sh +++ b/27/fpm/entrypoint.sh @@ -202,6 +202,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP file_env POSTGRES_USER install=false + db_wait='1s' if [ -n "${SQLITE_DATABASE+x}" ]; then echo "Installing with SQLite database" # shellcheck disable=SC2016 @@ -212,27 +213,31 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP # shellcheck disable=SC2016 install_options=$install_options' --database mysql --database-name "$MYSQL_DATABASE" --database-user "$MYSQL_USER" --database-pass "$MYSQL_PASSWORD" --database-host "$MYSQL_HOST"' install=true + db_wait='10s' elif [ -n "${POSTGRES_DB+x}" ] && [ -n "${POSTGRES_USER+x}" ] && [ -n "${POSTGRES_PASSWORD+x}" ] && [ -n "${POSTGRES_HOST+x}" ]; then echo "Installing with PostgreSQL database" # shellcheck disable=SC2016 install_options=$install_options' --database pgsql --database-name "$POSTGRES_DB" --database-user "$POSTGRES_USER" --database-pass "$POSTGRES_PASSWORD" --database-host "$POSTGRES_HOST"' install=true + db_wait='10s' fi if [ "$install" = true ]; then run_path pre-installation - echo "Starting nextcloud installation" + echo "Starting Nextcloud installation" max_retries=10 try=0 + echo "Waiting ($db_wait) for initialization of database to complete (NOTE: if this fails the first time we'll retry again in 10s)..." + sleep $db_wait until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] do - echo "Retrying install..." + echo "Retrying installation..." try=$((try+1)) sleep 10s done if [ "$try" -gt "$max_retries" ]; then - echo "Installing of nextcloud failed!" + echo "Installation of Nextcloud failed!" exit 1 fi if [ -n "${NEXTCLOUD_TRUSTED_DOMAINS+x}" ]; then diff --git a/28/apache/entrypoint.sh b/28/apache/entrypoint.sh index 5b627f076..70ebc709f 100755 --- a/28/apache/entrypoint.sh +++ b/28/apache/entrypoint.sh @@ -202,6 +202,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP file_env POSTGRES_USER install=false + db_wait='1s' if [ -n "${SQLITE_DATABASE+x}" ]; then echo "Installing with SQLite database" # shellcheck disable=SC2016 @@ -212,27 +213,31 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP # shellcheck disable=SC2016 install_options=$install_options' --database mysql --database-name "$MYSQL_DATABASE" --database-user "$MYSQL_USER" --database-pass "$MYSQL_PASSWORD" --database-host "$MYSQL_HOST"' install=true + db_wait='10s' elif [ -n "${POSTGRES_DB+x}" ] && [ -n "${POSTGRES_USER+x}" ] && [ -n "${POSTGRES_PASSWORD+x}" ] && [ -n "${POSTGRES_HOST+x}" ]; then echo "Installing with PostgreSQL database" # shellcheck disable=SC2016 install_options=$install_options' --database pgsql --database-name "$POSTGRES_DB" --database-user "$POSTGRES_USER" --database-pass "$POSTGRES_PASSWORD" --database-host "$POSTGRES_HOST"' install=true + db_wait='10s' fi if [ "$install" = true ]; then run_path pre-installation - echo "Starting nextcloud installation" + echo "Starting Nextcloud installation" max_retries=10 try=0 + echo "Waiting ($db_wait) for initialization of database to complete (NOTE: if this fails the first time we'll retry again in 10s)..." + sleep $db_wait until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] do - echo "Retrying install..." + echo "Retrying installation..." try=$((try+1)) sleep 10s done if [ "$try" -gt "$max_retries" ]; then - echo "Installing of nextcloud failed!" + echo "Installation of Nextcloud failed!" exit 1 fi if [ -n "${NEXTCLOUD_TRUSTED_DOMAINS+x}" ]; then diff --git a/28/fpm-alpine/entrypoint.sh b/28/fpm-alpine/entrypoint.sh index 5b627f076..70ebc709f 100755 --- a/28/fpm-alpine/entrypoint.sh +++ b/28/fpm-alpine/entrypoint.sh @@ -202,6 +202,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP file_env POSTGRES_USER install=false + db_wait='1s' if [ -n "${SQLITE_DATABASE+x}" ]; then echo "Installing with SQLite database" # shellcheck disable=SC2016 @@ -212,27 +213,31 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP # shellcheck disable=SC2016 install_options=$install_options' --database mysql --database-name "$MYSQL_DATABASE" --database-user "$MYSQL_USER" --database-pass "$MYSQL_PASSWORD" --database-host "$MYSQL_HOST"' install=true + db_wait='10s' elif [ -n "${POSTGRES_DB+x}" ] && [ -n "${POSTGRES_USER+x}" ] && [ -n "${POSTGRES_PASSWORD+x}" ] && [ -n "${POSTGRES_HOST+x}" ]; then echo "Installing with PostgreSQL database" # shellcheck disable=SC2016 install_options=$install_options' --database pgsql --database-name "$POSTGRES_DB" --database-user "$POSTGRES_USER" --database-pass "$POSTGRES_PASSWORD" --database-host "$POSTGRES_HOST"' install=true + db_wait='10s' fi if [ "$install" = true ]; then run_path pre-installation - echo "Starting nextcloud installation" + echo "Starting Nextcloud installation" max_retries=10 try=0 + echo "Waiting ($db_wait) for initialization of database to complete (NOTE: if this fails the first time we'll retry again in 10s)..." + sleep $db_wait until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] do - echo "Retrying install..." + echo "Retrying installation..." try=$((try+1)) sleep 10s done if [ "$try" -gt "$max_retries" ]; then - echo "Installing of nextcloud failed!" + echo "Installation of Nextcloud failed!" exit 1 fi if [ -n "${NEXTCLOUD_TRUSTED_DOMAINS+x}" ]; then diff --git a/28/fpm/entrypoint.sh b/28/fpm/entrypoint.sh index 5b627f076..70ebc709f 100755 --- a/28/fpm/entrypoint.sh +++ b/28/fpm/entrypoint.sh @@ -202,6 +202,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP file_env POSTGRES_USER install=false + db_wait='1s' if [ -n "${SQLITE_DATABASE+x}" ]; then echo "Installing with SQLite database" # shellcheck disable=SC2016 @@ -212,27 +213,31 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP # shellcheck disable=SC2016 install_options=$install_options' --database mysql --database-name "$MYSQL_DATABASE" --database-user "$MYSQL_USER" --database-pass "$MYSQL_PASSWORD" --database-host "$MYSQL_HOST"' install=true + db_wait='10s' elif [ -n "${POSTGRES_DB+x}" ] && [ -n "${POSTGRES_USER+x}" ] && [ -n "${POSTGRES_PASSWORD+x}" ] && [ -n "${POSTGRES_HOST+x}" ]; then echo "Installing with PostgreSQL database" # shellcheck disable=SC2016 install_options=$install_options' --database pgsql --database-name "$POSTGRES_DB" --database-user "$POSTGRES_USER" --database-pass "$POSTGRES_PASSWORD" --database-host "$POSTGRES_HOST"' install=true + db_wait='10s' fi if [ "$install" = true ]; then run_path pre-installation - echo "Starting nextcloud installation" + echo "Starting Nextcloud installation" max_retries=10 try=0 + echo "Waiting ($db_wait) for initialization of database to complete (NOTE: if this fails the first time we'll retry again in 10s)..." + sleep $db_wait until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] do - echo "Retrying install..." + echo "Retrying installation..." try=$((try+1)) sleep 10s done if [ "$try" -gt "$max_retries" ]; then - echo "Installing of nextcloud failed!" + echo "Installation of Nextcloud failed!" exit 1 fi if [ -n "${NEXTCLOUD_TRUSTED_DOMAINS+x}" ]; then diff --git a/29/apache/entrypoint.sh b/29/apache/entrypoint.sh index 5b627f076..70ebc709f 100755 --- a/29/apache/entrypoint.sh +++ b/29/apache/entrypoint.sh @@ -202,6 +202,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP file_env POSTGRES_USER install=false + db_wait='1s' if [ -n "${SQLITE_DATABASE+x}" ]; then echo "Installing with SQLite database" # shellcheck disable=SC2016 @@ -212,27 +213,31 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP # shellcheck disable=SC2016 install_options=$install_options' --database mysql --database-name "$MYSQL_DATABASE" --database-user "$MYSQL_USER" --database-pass "$MYSQL_PASSWORD" --database-host "$MYSQL_HOST"' install=true + db_wait='10s' elif [ -n "${POSTGRES_DB+x}" ] && [ -n "${POSTGRES_USER+x}" ] && [ -n "${POSTGRES_PASSWORD+x}" ] && [ -n "${POSTGRES_HOST+x}" ]; then echo "Installing with PostgreSQL database" # shellcheck disable=SC2016 install_options=$install_options' --database pgsql --database-name "$POSTGRES_DB" --database-user "$POSTGRES_USER" --database-pass "$POSTGRES_PASSWORD" --database-host "$POSTGRES_HOST"' install=true + db_wait='10s' fi if [ "$install" = true ]; then run_path pre-installation - echo "Starting nextcloud installation" + echo "Starting Nextcloud installation" max_retries=10 try=0 + echo "Waiting ($db_wait) for initialization of database to complete (NOTE: if this fails the first time we'll retry again in 10s)..." + sleep $db_wait until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] do - echo "Retrying install..." + echo "Retrying installation..." try=$((try+1)) sleep 10s done if [ "$try" -gt "$max_retries" ]; then - echo "Installing of nextcloud failed!" + echo "Installation of Nextcloud failed!" exit 1 fi if [ -n "${NEXTCLOUD_TRUSTED_DOMAINS+x}" ]; then diff --git a/29/fpm-alpine/entrypoint.sh b/29/fpm-alpine/entrypoint.sh index 5b627f076..70ebc709f 100755 --- a/29/fpm-alpine/entrypoint.sh +++ b/29/fpm-alpine/entrypoint.sh @@ -202,6 +202,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP file_env POSTGRES_USER install=false + db_wait='1s' if [ -n "${SQLITE_DATABASE+x}" ]; then echo "Installing with SQLite database" # shellcheck disable=SC2016 @@ -212,27 +213,31 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP # shellcheck disable=SC2016 install_options=$install_options' --database mysql --database-name "$MYSQL_DATABASE" --database-user "$MYSQL_USER" --database-pass "$MYSQL_PASSWORD" --database-host "$MYSQL_HOST"' install=true + db_wait='10s' elif [ -n "${POSTGRES_DB+x}" ] && [ -n "${POSTGRES_USER+x}" ] && [ -n "${POSTGRES_PASSWORD+x}" ] && [ -n "${POSTGRES_HOST+x}" ]; then echo "Installing with PostgreSQL database" # shellcheck disable=SC2016 install_options=$install_options' --database pgsql --database-name "$POSTGRES_DB" --database-user "$POSTGRES_USER" --database-pass "$POSTGRES_PASSWORD" --database-host "$POSTGRES_HOST"' install=true + db_wait='10s' fi if [ "$install" = true ]; then run_path pre-installation - echo "Starting nextcloud installation" + echo "Starting Nextcloud installation" max_retries=10 try=0 + echo "Waiting ($db_wait) for initialization of database to complete (NOTE: if this fails the first time we'll retry again in 10s)..." + sleep $db_wait until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] do - echo "Retrying install..." + echo "Retrying installation..." try=$((try+1)) sleep 10s done if [ "$try" -gt "$max_retries" ]; then - echo "Installing of nextcloud failed!" + echo "Installation of Nextcloud failed!" exit 1 fi if [ -n "${NEXTCLOUD_TRUSTED_DOMAINS+x}" ]; then diff --git a/29/fpm/entrypoint.sh b/29/fpm/entrypoint.sh index 5b627f076..70ebc709f 100755 --- a/29/fpm/entrypoint.sh +++ b/29/fpm/entrypoint.sh @@ -202,6 +202,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP file_env POSTGRES_USER install=false + db_wait='1s' if [ -n "${SQLITE_DATABASE+x}" ]; then echo "Installing with SQLite database" # shellcheck disable=SC2016 @@ -212,27 +213,31 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP # shellcheck disable=SC2016 install_options=$install_options' --database mysql --database-name "$MYSQL_DATABASE" --database-user "$MYSQL_USER" --database-pass "$MYSQL_PASSWORD" --database-host "$MYSQL_HOST"' install=true + db_wait='10s' elif [ -n "${POSTGRES_DB+x}" ] && [ -n "${POSTGRES_USER+x}" ] && [ -n "${POSTGRES_PASSWORD+x}" ] && [ -n "${POSTGRES_HOST+x}" ]; then echo "Installing with PostgreSQL database" # shellcheck disable=SC2016 install_options=$install_options' --database pgsql --database-name "$POSTGRES_DB" --database-user "$POSTGRES_USER" --database-pass "$POSTGRES_PASSWORD" --database-host "$POSTGRES_HOST"' install=true + db_wait='10s' fi if [ "$install" = true ]; then run_path pre-installation - echo "Starting nextcloud installation" + echo "Starting Nextcloud installation" max_retries=10 try=0 + echo "Waiting ($db_wait) for initialization of database to complete (NOTE: if this fails the first time we'll retry again in 10s)..." + sleep $db_wait until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] do - echo "Retrying install..." + echo "Retrying installation..." try=$((try+1)) sleep 10s done if [ "$try" -gt "$max_retries" ]; then - echo "Installing of nextcloud failed!" + echo "Installation of Nextcloud failed!" exit 1 fi if [ -n "${NEXTCLOUD_TRUSTED_DOMAINS+x}" ]; then diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 5b627f076..70ebc709f 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -202,6 +202,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP file_env POSTGRES_USER install=false + db_wait='1s' if [ -n "${SQLITE_DATABASE+x}" ]; then echo "Installing with SQLite database" # shellcheck disable=SC2016 @@ -212,27 +213,31 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP # shellcheck disable=SC2016 install_options=$install_options' --database mysql --database-name "$MYSQL_DATABASE" --database-user "$MYSQL_USER" --database-pass "$MYSQL_PASSWORD" --database-host "$MYSQL_HOST"' install=true + db_wait='10s' elif [ -n "${POSTGRES_DB+x}" ] && [ -n "${POSTGRES_USER+x}" ] && [ -n "${POSTGRES_PASSWORD+x}" ] && [ -n "${POSTGRES_HOST+x}" ]; then echo "Installing with PostgreSQL database" # shellcheck disable=SC2016 install_options=$install_options' --database pgsql --database-name "$POSTGRES_DB" --database-user "$POSTGRES_USER" --database-pass "$POSTGRES_PASSWORD" --database-host "$POSTGRES_HOST"' install=true + db_wait='10s' fi if [ "$install" = true ]; then run_path pre-installation - echo "Starting nextcloud installation" + echo "Starting Nextcloud installation" max_retries=10 try=0 + echo "Waiting ($db_wait) for initialization of database to complete (NOTE: if this fails the first time we'll retry again in 10s)..." + sleep $db_wait until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] do - echo "Retrying install..." + echo "Retrying installation..." try=$((try+1)) sleep 10s done if [ "$try" -gt "$max_retries" ]; then - echo "Installing of nextcloud failed!" + echo "Installation of Nextcloud failed!" exit 1 fi if [ -n "${NEXTCLOUD_TRUSTED_DOMAINS+x}" ]; then