Try to auto-detect PG_MAIN directory.
Benjamin Renard

Benjamin Renard commited on 2017-08-25 14:19:15
Showing 1 changed files, with 9 additions and 3 deletions.

... ...
@@ -19,9 +19,14 @@
19 19
 PG_USER=postgres
20 20
 PSQL_BIN=/usr/bin/psql
21 21
 PG_MAIN=/var/lib/postgresql/9.1/main
22
-if [ -f /etc/redhat-release ]
22
+if [ -f /etc/debian_version ]
23 23
 then
24
-	PG_MAIN=/var/lib/pgsql/9.1/data
24
+	AUTO_PG_MAIN=$( ls -1d /var/lib/postgresql/9*/main 2> /dev/null|sort -n|tail -n 1 )
25
+	[ -n "$AUTO_PG_MAIN" -a -d "$AUTO_PG_MAIN" ] && PG_MAIN=$AUTO_PG_MAIN
26
+elif [ -f /etc/redhat-release ]
27
+then
28
+	AUTO_PG_MAIN=$( ls -1d /var/lib/pgsql/9*/data 2> /dev/null|sort -n|tail -n 1 )
29
+	[ -n "$AUTO_PG_MAIN" -a -d "$AUTO_PG_MAIN" ] && PG_MAIN=$AUTO_PG_MAIN
25 30
 fi
26 31
 RECOVERY_CONF_FILENAME=recovery.conf
27 32
 RECOVERY_CONF=""
... ...
@@ -36,7 +41,8 @@ Usage : $0 [-d] [-h] [options]
36 41
 	-u pg_user		Specify Postgres user (Default : $PG_USER)
37 42
 	-b psql_bin		Specify psql binary path (Default : $PSQL_BIN)
38 43
 	-m pg_main		Specify Postgres main directory path
39
-				(Default : $PG_MAIN)
44
+				(By default, try to auto-detect it, on your system it :
45
+                                $PG_MAIN)
40 46
 	-r recovery_conf	Specify Postgres recovery configuration file path
41 47
 				(Default : $PG_MAIN/$RECOVERY_CONF_FILENAME)
42 48
 	-p pg_port		Specify default Postgres master TCP port (Default : $PG_DEFAULT_PORT)
43 49