diff --git a/Containers/nextcloud/entrypoint.sh b/Containers/nextcloud/entrypoint.sh index 1abbcd5e9e2..ae57767977d 100644 --- a/Containers/nextcloud/entrypoint.sh +++ b/Containers/nextcloud/entrypoint.sh @@ -20,6 +20,11 @@ run_upgrade_if_needed_due_to_app_update() { fi } +# Adjust DATABASE_TYPE to by Nextcloud supported value +if [ "$DATABASE_TYPE" = postgres ]; then + export DATABASE_TYPE=pgsql +fi + # Only start container if redis is accessible # shellcheck disable=SC2153 while ! nc -z "$REDIS_HOST" "6379"; do @@ -237,12 +242,12 @@ if ! [ -f "$NEXTCLOUD_DATA_DIR/skip.update" ]; then ); DATADIR_PERMISSION_CONF - echo "Installing with PostgreSQL database" + echo "Installing with $DATABASE_TYPE database" # Set a default value for POSTGRES_PORT if [ -z "$POSTGRES_PORT" ]; then POSTGRES_PORT=5432 fi - INSTALL_OPTIONS+=(--database pgsql --database-name "$POSTGRES_DB" --database-user "$POSTGRES_USER" --database-pass "$POSTGRES_PASSWORD" --database-host "$POSTGRES_HOST" --database-port "$POSTGRES_PORT") + INSTALL_OPTIONS+=(--database "$DATABASE_TYPE" --database-name "$POSTGRES_DB" --database-user "$POSTGRES_USER" --database-pass "$POSTGRES_PASSWORD" --database-host "$POSTGRES_HOST" --database-port "$POSTGRES_PORT") echo "Starting Nextcloud installation..." if ! php /var/www/html/occ maintenance:install "${INSTALL_OPTIONS[@]}"; then diff --git a/Containers/nextcloud/start.sh b/Containers/nextcloud/start.sh index 0bbea7394e1..37aa4d98d46 100644 --- a/Containers/nextcloud/start.sh +++ b/Containers/nextcloud/start.sh @@ -17,6 +17,11 @@ done POSTGRES_USER="oc_$POSTGRES_USER" export POSTGRES_USER +# Check that db type is not empty +if [ -z "$DATABASE_TYPE" ]; then + export DATABASE_TYPE=postgres +fi + # Fix false database connection on old instances if [ -f "/var/www/html/config/config.php" ]; then sleep 2 diff --git a/Containers/notify-push/start.sh b/Containers/notify-push/start.sh index 1f77b0f1c1e..21b291d08c8 100644 --- a/Containers/notify-push/start.sh +++ b/Containers/notify-push/start.sh @@ -1,13 +1,13 @@ #!/bin/bash if [ -z "$NEXTCLOUD_HOST" ]; then - echo "NEXTCLOUD_HOST need to be provided. Exiting!" + echo "NEXTCLOUD_HOST needs to be provided. Exiting!" exit 1 elif [ -z "$POSTGRES_HOST" ]; then - echo "POSTGRES_HOST need to be provided. Exiting!" + echo "POSTGRES_HOST needs to be provided. Exiting!" exit 1 elif [ -z "$REDIS_HOST" ]; then - echo "REDIS_HOST need to be provided. Exiting!" + echo "REDIS_HOST needs to be provided. Exiting!" exit 1 fi @@ -52,9 +52,16 @@ fi if [ -z "$REDIS_DB_INDEX" ]; then REDIS_DB_INDEX=0 fi +# Set a default for db type +if [ -z "$DATABASE_TYPE" ]; then + DATABASE_TYPE=postgres +elif [ "$DATABASE_TYPE" != postgres ] && [ "$DATABASE_TYPE" != mysql ]; then + echo "DB type must be either postgres or mysql" + exit 1 +fi # Set sensitive values as env -export DATABASE_URL="postgres://oc_$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:$POSTGRES_PORT/$POSTGRES_DB" +export DATABASE_URL="$DATABASE_TYPE://oc_$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:$POSTGRES_PORT/$POSTGRES_DB" export REDIS_URL="redis://:$REDIS_HOST_PASSWORD@$REDIS_HOST/$REDIS_DB_INDEX" # Run it