Benjamin Renard commited on 2017-08-25 14:18:51
Showing 1 changed files, with 6 additions and 3 deletions.
... | ... |
@@ -26,7 +26,7 @@ fi |
26 | 26 |
RECOVERY_CONF_FILENAME=recovery.conf |
27 | 27 |
RECOVERY_CONF="" |
28 | 28 |
PG_DEFAULT_PORT=5432 |
29 |
-PG_DB=template0 |
|
29 |
+PG_DB="" |
|
30 | 30 |
|
31 | 31 |
DEBUG=0 |
32 | 32 |
|
... | ... |
@@ -40,7 +40,7 @@ Usage : $0 [-d] [-h] [options] |
40 | 40 |
-r recovery_conf Specify Postgres recovery configuration file path |
41 | 41 |
(Default : $PG_MAIN/$RECOVERY_CONF_FILENAME) |
42 | 42 |
-p pg_port Specify default Postgres master TCP port (Default : $PG_DEFAULT_PORT) |
43 |
- -D dbname Specify DB name on Postgres master to connect on (Default : $PG_DB) |
|
43 |
+ -D dbname Specify DB name on Postgres master/slave to connect on (Default : PG_USER) |
|
44 | 44 |
-d Debug mode |
45 | 45 |
-h Show this message |
46 | 46 |
EOF |
... | ... |
@@ -97,8 +97,11 @@ id "$PG_USER" > /dev/null 2>&1 |
97 | 97 |
# Check PG_DEFAULT_PORT |
98 | 98 |
[ $( echo "$PG_DEFAULT_PORT"|grep -c -E '^[0-9]*$' ) -ne 1 ] && "UNKNOWN : Postgres default master TCP port must be an integer." && exit 3 |
99 | 99 |
|
100 |
+# If PG_DB is not provided with -D parameter, use PG_USER as default value |
|
101 |
+[ -z "$PB_DB" ] && PG_DB="$PG_USER" |
|
102 |
+ |
|
100 | 103 |
function psql_get () { |
101 |
- echo "$1"|su - $PG_USER -c "$PSQL_BIN -t -P format=unaligned" |
|
104 |
+ echo "$1"|su - $PG_USER -c "$PSQL_BIN -d "$PG_DB" -t -P format=unaligned" |
|
102 | 105 |
} |
103 | 106 |
|
104 | 107 |
function debug() { |
105 | 108 |