fork 0k-charms
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
435 B

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