diff --git a/start b/start index 6cc19f2ae..27c6c7971 100755 --- a/start +++ b/start @@ -152,28 +152,39 @@ fi # Wait for database to get available TIMEOUT=0 -until psql -h "$POSTGRES_HOST" -p "$POSTGRES_PORT" -d "$POSTGRES_DATABASE" -U "$POSTGRES_USER" -c 'SELECT 1' > /dev/null ; do - >&2 echo "Postgres at ${POSTGRES_HOST:-db} is unavailable - retrying $((30 - TIMEOUT))" +until run_weblate shell -c 'from weblate.auth.models import User; User.objects.raw("SELECT 1")' > /dev/null ; do + >&2 echo "Database server at ${POSTGRES_HOST:-db} is unavailable - retrying $((30 - TIMEOUT))" TIMEOUT=$((TIMEOUT + 1)) if [ $TIMEOUT -gt 30 ] ; then - psql -h "$POSTGRES_HOST" -p "$POSTGRES_PORT" -d "$POSTGRES_DATABASE" -U "$POSTGRES_USER" -c 'SELECT 1' + run_weblate shell -c 'from weblate.auth.models import User; User.objects.exists()' fail_dep PosgreSQL fi sleep 1 done -# Fetch server version -PGVERSION=$(psql -h "$POSTGRES_HOST" -p "$POSTGRES_PORT" -d "$POSTGRES_DATABASE" -U "$POSTGRES_USER" -t -A -c 'SHOW server_version_num;') +VERSION_CHECK=1 +case $WEBLATE_DATABASES in + 0|[fF][aA][lL][sS][eE]|[nN][oO]) + VERSION_CHECK=0 + ;; +esac -unset PGPASSWORD +if [ $VERSION_CHECK -eq 1 ] ; then + # Fetch server version + PGVERSION=$(psql -h "$POSTGRES_HOST" -p "$POSTGRES_PORT" -d "$POSTGRES_DATABASE" -U "$POSTGRES_USER" -t -A -c 'SHOW server_version_num;') ->&2 echo "Postgres $PGVERSION is up" + unset PGPASSWORD -# Check if supported PostgreSQL version is used -if [ "$PGVERSION" -lt 120000 ] ; then - >&2 echo "PostgreSQL 12 or newer is required to run Weblate" - >&2 echo "See https://docs.weblate.org/en/latest/admin/install/docker.html#upgrading-postgresql-container" - exit 1 + >&2 echo "Postgres $PGVERSION is up" + + # Check if supported PostgreSQL version is used + if [ "$PGVERSION" -lt 120000 ] ; then + >&2 echo "PostgreSQL 12 or newer is required to run Weblate" + >&2 echo "See https://docs.weblate.org/en/latest/admin/install/docker.html#upgrading-postgresql-container" + exit 1 + fi +else + >&2 echo "Database is up" fi # Migrate database to current version and collect static files