diff --git a/check_pg_streaming_replication b/check_pg_streaming_replication index fcd2745..c8a222d 100755 --- a/check_pg_streaming_replication +++ b/check_pg_streaming_replication @@ -34,7 +34,6 @@ PG_MAIN="" PG_MASTER_USER="" PSQL_BIN=/usr/bin/psql PG_LSCLUSTER_BIN=/usr/bin/pg_lsclusters -RECOVERY_CONF_FILENAME=recovery.conf RECOVERY_CONF="" PG_DEFAULT_PORT="" PG_DEFAULT_APP_NAME=$( hostname ) @@ -55,7 +54,7 @@ Usage: $0 [-d] [-h] [options] -m pg_main Specify Postgres main directory path (Default: try to auto-detect or use $DEFAULT_PG_MAIN) -r recovery_conf Specify Postgres recovery configuration file path - (Default: [PG_MAIN]/$RECOVERY_CONF_FILENAME) + (Default: [PG_MAIN]/recovery.conf on PG <= 11, [PG_MAIN]/postgresql.auto.conf on PG >= 12) -U pg_master_user Specify Postgres user to use on master (Default: user from recovery.conf file) -p pg_port Specify default Postgres master TCP port (Default: same as local PostgreSQL port if detected or use $DEFAULT_PG_PORT) @@ -180,7 +179,10 @@ id "$PG_USER" > /dev/null 2>&1 [ ! -d "$PG_MAIN/" ] && echo "UNKNOWN: Invalid Postgres main directory path ($PG_MAIN)" && exit 3 # Check RECOVERY_CONF -[ -z "$RECOVERY_CONF" ] && RECOVERY_CONF="$PG_MAIN/$RECOVERY_CONF_FILENAME" +if [ -z "$RECOVERY_CONF" ]; then + [ $PG_VERSION -le 11 ] && RECOVERY_CONF_FILENAME="recovery.conf" || RECOVERY_CONF_FILENAME="postgresql.auto.conf" + RECOVERY_CONF="$PG_MAIN/$RECOVERY_CONF_FILENAME" +fi # Check PG_DEFAULT_PORT [ $( echo "$PG_DEFAULT_PORT"|grep -c -E '^[0-9]*$' ) -ne 1 ] && "UNKNOWN: Postgres default master TCP port must be an integer." && exit 3