#!/bin/bash if [ "$WAIT_DB" != true ]; then log INFO Not waiting for a postgres server exit 0 fi log INFO Waiting until postgres is listening at $PGHOST... while true; do if [ -n "$PGDATABASE" ]; then echo "SELECT 1;" | psql "$PGDATABASE" else # Assumes that your access level to postgres includes the # right to list databases psql -l fi > /dev/null 2>&1 && break sleep 1 done