Add -D parameter and retreive master user in recovery.conf file
This commit is contained in:
parent
6892005c4d
commit
22bbb4223b
1 changed files with 16 additions and 2 deletions
|
@ -26,6 +26,7 @@ fi
|
|||
RECOVERY_CONF_FILENAME=recovery.conf
|
||||
RECOVERY_CONF=""
|
||||
PG_DEFAULT_PORT=5432
|
||||
PG_DB=template0
|
||||
|
||||
DEBUG=0
|
||||
|
||||
|
@ -39,13 +40,14 @@ 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 Debug mode
|
||||
-h Show this message
|
||||
EOF
|
||||
exit 0
|
||||
}
|
||||
|
||||
while getopts "hu:b:m:r:p:d" OPTION
|
||||
while getopts "hu:b:m:r:p:D:d" OPTION
|
||||
do
|
||||
case $OPTION in
|
||||
u)
|
||||
|
@ -63,6 +65,9 @@ do
|
|||
p)
|
||||
PG_DEFAULT_PORT=$OPTARG
|
||||
;;
|
||||
D)
|
||||
PG_DB=$OPTARG
|
||||
;;
|
||||
d)
|
||||
DEBUG=1
|
||||
;;
|
||||
|
@ -171,8 +176,17 @@ then
|
|||
debug "Master port : $M_PORT"
|
||||
fi
|
||||
|
||||
M_USER=$( echo "$MASTER_CONN_INFOS"|sed 's/^.*user= *\([^ ]*\) *.*$/\1/' )
|
||||
if [ ! -n "$M_USER" ]
|
||||
then
|
||||
debug "Master user not specify, use default : $PG_USER"
|
||||
M_USER=$PG_USER
|
||||
else
|
||||
debug "Master user : $M_USER"
|
||||
fi
|
||||
|
||||
# Get current xlog file from master
|
||||
M_CUR_XLOG="$( echo 'SELECT pg_current_xlog_location()'|su - $PG_USER -c "$PSQL_BIN -h $M_HOST -p $M_PORT -t -P format=unaligned" )"
|
||||
M_CUR_XLOG="$( echo 'SELECT pg_current_xlog_location()'|su - $PG_USER -c "$PSQL_BIN -U $M_USER -h $M_HOST -p $M_PORT -d $PG_DB -t -P format=unaligned" )"
|
||||
if [ ! -n "$M_CUR_XLOG" ]
|
||||
then
|
||||
echo "UNKNOWN : Can't retreive current xlog from master server"
|
||||
|
|
Loading…
Reference in a new issue