diff --git a/Containers/postgresql/init-user-db.sh b/Containers/postgresql/init-user-db.sh index 1f09770b..8c1f2dc9 100644 --- a/Containers/postgresql/init-user-db.sh +++ b/Containers/postgresql/init-user-db.sh @@ -1,9 +1,13 @@ #!/bin/bash set -ex +touch "$DUMP_DIR/initialization.failed" + psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL CREATE USER "oc_$POSTGRES_USER" WITH PASSWORD '$POSTGRES_PASSWORD' CREATEDB; ALTER DATABASE "$POSTGRES_DB" OWNER TO "oc_$POSTGRES_USER"; EOSQL +rm "$DUMP_DIR/initialization.failed" + set +ex diff --git a/Containers/postgresql/start.sh b/Containers/postgresql/start.sh index 971bb6cc..dfc728b8 100644 --- a/Containers/postgresql/start.sh +++ b/Containers/postgresql/start.sh @@ -2,7 +2,7 @@ # Variables DATADIR="/var/lib/postgresql/data" -DUMP_DIR="/mnt/data" +export DUMP_DIR="/mnt/data" DUMP_FILE="$DUMP_DIR/database-dump.sql" export PGPASSWORD="$POSTGRES_PASSWORD" @@ -27,6 +27,16 @@ if [ -f "$DUMP_DIR/import.failed" ]; then exit 1 fi +# Don't start if initialization failed +if [ -f "$DUMP_DIR/initialization.failed" ]; then + echo "The database initialization failed. Most likely was a wrong timezone selected." + echo "The selected timezone is '$TZ'." + echo "Please check if it is in 'TZ database name' column of the timezone list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List" + echo "For further clues on what went wrong, look at the logs above." + echo "You might start again from scratch by following https://github.com/nextcloud/all-in-one#how-to-properly-reset-the-instance and selecting a proper timezone." + exit 1 +fi + # Delete the datadir once (needed for setting the correct credentials on old instances once) if ! [ -f "$DUMP_DIR/export.failed" ] && ! [ -f "$DUMP_DIR/initial-cleanup-done" ]; then set -ex