+

viewgit/inc/functions.php:74 Function create_function() is deprecated [8192]

Try to auto-detect PG_MAIN directory.

Benjamin Renard [2017-08-25 14:19:15]
Try to auto-detect PG_MAIN directory.
Filename
check_pg_streaming_replication
diff --git a/check_pg_streaming_replication b/check_pg_streaming_replication
index 2c13a0a..b8ca958 100755
--- a/check_pg_streaming_replication
+++ b/check_pg_streaming_replication
@@ -19,9 +19,14 @@
 PG_USER=postgres
 PSQL_BIN=/usr/bin/psql
 PG_MAIN=/var/lib/postgresql/9.1/main
-if [ -f /etc/redhat-release ]
+if [ -f /etc/debian_version ]
 then
-	PG_MAIN=/var/lib/pgsql/9.1/data
+	AUTO_PG_MAIN=$( ls -1d /var/lib/postgresql/9*/main 2> /dev/null|sort -n|tail -n 1 )
+	[ -n "$AUTO_PG_MAIN" -a -d "$AUTO_PG_MAIN" ] && PG_MAIN=$AUTO_PG_MAIN
+elif [ -f /etc/redhat-release ]
+then
+	AUTO_PG_MAIN=$( ls -1d /var/lib/pgsql/9*/data 2> /dev/null|sort -n|tail -n 1 )
+	[ -n "$AUTO_PG_MAIN" -a -d "$AUTO_PG_MAIN" ] && PG_MAIN=$AUTO_PG_MAIN
 fi
 RECOVERY_CONF_FILENAME=recovery.conf
 RECOVERY_CONF=""
@@ -36,7 +41,8 @@ Usage : $0 [-d] [-h] [options]
 	-u pg_user		Specify Postgres user (Default : $PG_USER)
 	-b psql_bin		Specify psql binary path (Default : $PSQL_BIN)
 	-m pg_main		Specify Postgres main directory path
-				(Default : $PG_MAIN)
+				(By default, try to auto-detect it, on your system it :
+                                $PG_MAIN)
 	-r recovery_conf	Specify Postgres recovery configuration file path
 				(Default : $PG_MAIN/$RECOVERY_CONF_FILENAME)
 	-p pg_port		Specify default Postgres master TCP port (Default : $PG_DEFAULT_PORT)
ViewGit