Add -U parameter to provide user to use on master host
This commit is contained in:
parent
4efda74bf6
commit
690811ccfb
1 changed files with 17 additions and 6 deletions
|
@ -20,6 +20,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
PG_USER=postgres
|
PG_USER=postgres
|
||||||
|
PG_MASTER_USER=""
|
||||||
PSQL_BIN=/usr/bin/psql
|
PSQL_BIN=/usr/bin/psql
|
||||||
PG_MAIN=/var/lib/postgresql/9.1/main
|
PG_MAIN=/var/lib/postgresql/9.1/main
|
||||||
if [ -f /etc/debian_version ]
|
if [ -f /etc/debian_version ]
|
||||||
|
@ -48,6 +49,7 @@ Usage : $0 [-d] [-h] [options]
|
||||||
$PG_MAIN)
|
$PG_MAIN)
|
||||||
-r recovery_conf Specify Postgres recovery configuration file path
|
-r recovery_conf Specify Postgres recovery configuration file path
|
||||||
(Default : [PG_MAIN]/$RECOVERY_CONF_FILENAME)
|
(Default : [PG_MAIN]/$RECOVERY_CONF_FILENAME)
|
||||||
|
-U pg_master_user Specify Postgres user to use on master (Default : user from recovery.conf file)
|
||||||
-p pg_port Specify default Postgres master TCP port (Default : $PG_DEFAULT_PORT)
|
-p pg_port Specify default Postgres master TCP port (Default : $PG_DEFAULT_PORT)
|
||||||
-D dbname Specify DB name on Postgres master/slave to connect on (Default : PG_USER)
|
-D dbname Specify DB name on Postgres master/slave to connect on (Default : PG_USER)
|
||||||
-d Debug mode
|
-d Debug mode
|
||||||
|
@ -56,7 +58,7 @@ EOF
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts "hu:b:m:r:p:D:d" OPTION
|
while getopts "hu:b:m:r:U:p:D:d" OPTION
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
u)
|
u)
|
||||||
|
@ -71,6 +73,9 @@ do
|
||||||
r)
|
r)
|
||||||
RECOVERY_CONF=$OPTARG
|
RECOVERY_CONF=$OPTARG
|
||||||
;;
|
;;
|
||||||
|
U)
|
||||||
|
PG_MASTER_USER=$OPTARG
|
||||||
|
;;
|
||||||
p)
|
p)
|
||||||
PG_DEFAULT_PORT=$OPTARG
|
PG_DEFAULT_PORT=$OPTARG
|
||||||
;;
|
;;
|
||||||
|
@ -188,13 +193,19 @@ then
|
||||||
debug "Master port : $M_PORT"
|
debug "Master port : $M_PORT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
M_USER=$( echo "$MASTER_CONN_INFOS"|sed 's/^.*user= *\([^ ]*\) *.*$/\1/' )
|
if [ -n "$PG_MASTER_USER" ]
|
||||||
if [ ! -n "$M_USER" ]
|
|
||||||
then
|
then
|
||||||
debug "Master user not specify, use default : $PG_USER"
|
debug "Master user provided by command-line, use it : $PG_MASTER_USER"
|
||||||
M_USER=$PG_USER
|
M_USER="$PG_MASTER_USER"
|
||||||
else
|
else
|
||||||
debug "Master user : $M_USER"
|
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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get current xlog file from master
|
# Get current xlog file from master
|
||||||
|
|
Loading…
Reference in a new issue