#!/bin/bash ROLE=$(psql -U postgres -tAc "SELECT pg_is_in_recovery();") [ "$ROLE" = "f" ] && echo "primary" || echo "replica"