* debian/pg_createconfig_patroni: Parse multiple DCS endpoints correctly,

patch by Tomas Pospisek (Closes: #953197).
This commit is contained in:
Michael Banck 2020-05-08 16:33:42 +02:00
parent 538d5412e2
commit f2b7f40628
2 changed files with 10 additions and 5 deletions

2
debian/changelog vendored
View file

@ -5,6 +5,8 @@ patroni (1.6.5-3) UNRELEASED; urgency=medium
in case more than one major version of PostgreSQL is installed.
* debian/config.yml.in: Add commented out section on a rewind user, that can
be used on PostgreSQL 11+ to run pg_rewind as a non-superuser.
* debian/pg_createconfig_patroni: Parse multiple DCS endpoints correctly,
patch by Tomas Pospisek (Closes: #953197).
-- Debian PostgreSQL Maintainers <team+postgresql@tracker.debian.org> Thu, 07 May 2020 13:41:58 +0200

View file

@ -24,6 +24,7 @@ case $i in
shift # past argument=value
;;
--endpoint=*)
# one or more endpoints joined by commas are allowed
DCS_ENDPOINT="${i#*=}"
shift # past argument=value
;;
@ -138,18 +139,20 @@ if [ -n "$VIP_IP" ]; then
exit 1
fi
if [ -z "$DCS_ENDPOINT" ]; then
DCS_ENDPOINT="$(egrep -v '^[[:space:]]*$|^ *#' /etc/patroni/dcs.yml | egrep '(host|-)' | egrep '[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+' | sed -r -e s/.*host:// -e s/-// -e 's/ //g' -e 's/^([0-9])/http:\/\/\1/')"
DCS_ENDPOINT="$(egrep -v '^[[:space:]]*$|^ *#' /etc/patroni/dcs.yml | egrep '(host|-)' | egrep -v '^[[:space:]]*$' | egrep '[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+' | sed -r -e s/.*host:// -e s/-// -e 's/ //g' -e 's/^([0-9])/http:\/\/\1/')"
if [ -z "$DCS_ENDPOINT" ]; then
echo "DCS endpoint URL could not be determined from /etc/patroni/dcs.yml and --endpoint not provided, cannot write VIP file"
exit 1
fi
if [ $(echo "$DCS_ENDPOINT" | wc -l) != 1 ]; then
echo "DCS endpoint URL could not be determined from /etc/patroni/dcs.yml and --endpoint not provided, cannot write VIP file"
exit 1
# join multiple lines with commas
# sed -> remove trailing comma
DCS_ENDPOINT=$( echo "$DCS_ENDPOINT" | tr '\n' ',' | sed 's/,$//' )
fi
fi
if ! $(echo "$DCS_ENDPOINT" | egrep -q '^http.*://[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+:[[:digit:]]+$'); then
echo "DCS endpoint URL not in 'http://1.2.3.4:1234' format, cannot write VIP file"
if ! $(echo "$DCS_ENDPOINT" | egrep -q '^(http.*://[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+:[[:digit:]]+){1}(,http.*://[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+:[[:digit:]]+)*$'); then
echo "DCS_ENDPOINT: $DCS_ENDPOINT"
echo "DCS endpoint URL not in 'http://1.2.3.4:1234[,http://2.3.4.5:1234]*' format, cannot write VIP file"
exit 1
fi
LISTEN_VIP=",$VIP_IP"