Files
vote/healthchecks/postgres.sh
Scaffolder 3f7396407b
Some checks failed
CI Pipeline / Build and Test (push) Has been cancelled
Build and Publish TechDocs / build-and-publish (push) Has been cancelled
initial commit
Change-Id: Ia748646eaf5c18f44eb5b147ff577d0d5ee844e8
2026-03-23 17:40:04 +00:00

22 lines
465 B
Bash
Executable File

#!/bin/bash
set -eo pipefail
host="$(hostname -i || echo '127.0.0.1')"
user="${POSTGRES_USER:-postgres}"
db="${POSTGRES_DB:-$POSTGRES_USER}"
export PGPASSWORD="${POSTGRES_PASSWORD:-}"
args=(
# force postgres to not use the local unix socket (test "external" connectibility)
--host "$host"
--username "$user"
--dbname "$db"
--quiet --no-align --tuples-only
)
if select="$(echo 'SELECT 1' | psql "${args[@]}")" && [ "$select" = '1' ]; then
exit 0
fi
exit 1