Improve master connection informations detection reliability

This commit is contained in:
Benjamin Renard 2019-03-15 16:29:07 +01:00
parent be30219100
commit f883216050

View file

@ -170,7 +170,7 @@ then
# Get master connection informations from recovery.conf file
MASTER_CONN_INFOS=$( egrep '^ *primary_conninfo' $RECOVERY_CONF|sed "s/^ *primary_conninfo *= *[\"\']\([^\"\']*\)[\"\'].*$/\1/" )
MASTER_CONN_INFOS=$( egrep '^ *primary_conninfo' $RECOVERY_CONF|sed "s/^ *primary_conninfo *= *\(.\+\) *$/\1/" )
if [ ! -n "$MASTER_CONN_INFOS" ]
then
echo "UNKNOWN : Can't retreive master connection informations form recovery.conf file"
@ -178,7 +178,7 @@ then
fi
debug "Master connection informations : $MASTER_CONN_INFOS"
M_HOST=$( echo "$MASTER_CONN_INFOS"|sed 's/^.*host= *\([^ ]*\) *.*$/\1/' )
M_HOST=$( echo "$MASTER_CONN_INFOS"| grep 'host=' | sed 's/^.*host= *\([0-9a-zA-Z.-]\+\) *.*$/\1/' )
if [ ! -n "$M_HOST" ]
then
echo "UNKNOWN : Can't retreive master host from recovery.conf file"
@ -200,7 +200,7 @@ then
debug "Master user provided by command-line, use it : $PG_MASTER_USER"
M_USER="$PG_MASTER_USER"
else
M_USER=$( echo "$MASTER_CONN_INFOS"|sed 's/^.*user= *\([^ ]*\) *.*$/\1/' )
M_USER=$( echo "$MASTER_CONN_INFOS"| grep 'user=' | sed 's/^.*user= *\([0-9a-zA-Z.-]\+\) *.*$/\1/' )
if [ ! -n "$M_USER" ]
then
debug "Master user not specified, use default : $PG_USER"