Use PG_DB also on slave and use PG_USER as default value.

This commit is contained in:
Benjamin Renard 2017-08-25 16:18:51 +02:00
parent 22bbb4223b
commit d8a4cfac51

View file

@ -26,7 +26,7 @@ fi
RECOVERY_CONF_FILENAME=recovery.conf
RECOVERY_CONF=""
PG_DEFAULT_PORT=5432
PG_DB=template0
PG_DB=""
DEBUG=0
@ -40,7 +40,7 @@ Usage : $0 [-d] [-h] [options]
-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)
-D dbname Specify DB name on Postgres master to connect on (Default : $PG_DB)
-D dbname Specify DB name on Postgres master/slave to connect on (Default : PG_USER)
-d Debug mode
-h Show this message
EOF
@ -97,8 +97,11 @@ id "$PG_USER" > /dev/null 2>&1
# 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
# If PG_DB is not provided with -D parameter, use PG_USER as default value
[ -z "$PB_DB" ] && PG_DB="$PG_USER"
function psql_get () {
echo "$1"|su - $PG_USER -c "$PSQL_BIN -t -P format=unaligned"
echo "$1"|su - $PG_USER -c "$PSQL_BIN -d "$PG_DB" -t -P format=unaligned"
}
function debug() {