16 lines
278 B
Bash
Executable File
16 lines
278 B
Bash
Executable File
#!/bin/sh
|
|
# wait-for-db.sh
|
|
|
|
set -e
|
|
|
|
host="$1"
|
|
shift
|
|
cmd="$@"
|
|
|
|
until PGPASSWORD=$POSTGRES_PASSWORD psql -h "$host" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c '\q'; do
|
|
echo "Waiting for database at $host..."
|
|
sleep 2
|
|
done
|
|
|
|
echo "Database is ready, executing command..."
|
|
exec $cmd |