* debian/pg_createconfig_patroni: Load DCS configuration into $DCS_CONFIG

variable and replace both @HOSTNAME@ and @DCS_CONFIG@ placeholders in
    config template.
This commit is contained in:
Michael Banck 2019-01-21 14:43:53 +01:00
parent f0d6e56a90
commit 48cc554f41
2 changed files with 11 additions and 14 deletions

3
debian/changelog vendored
View file

@ -3,6 +3,9 @@ patroni (1.5.4-2) UNRELEASED; urgency=medium
[ Michael Banck ]
* debian/config.yml.in: Remove DCS-related commented-out lines and replace
them with @DCS_CONFIG@ placeholder.
* debian/pg_createconfig_patroni: Load DCS configuration into $DCS_CONFIG
variable and replace both @HOSTNAME@ and @DCS_CONFIG@ placeholders in
config template.
-- Debian PostgreSQL Maintainers <team+postgresql@tracker.debian.org> Tue, 15 Jan 2019 19:12:36 +0100

View file

@ -62,6 +62,7 @@ if [ $? != 0 ]; then
echo "DCS not configured yet, edit /etc/patroni/dcs.yml"
exit 1
fi
DCS_CONFIG="$(cat /etc/patroni/dcs.yml | sed -e ':a;N;$!ba;s/\n/\\n/g' -e 's/\$/\\$/g')"
CONFIG_FILE=/etc/patroni/${VERSION}-${CLUSTER}.yml
@ -80,21 +81,14 @@ if [ -z "$HOSTIP" ]; then
HOSTIP=$(ip -4 route get 8.8.8.8 | grep ^8.8.8.8 | sed -e s/.*src.// -e s/\ //g)
fi
echo "scope: \"$VERSION-$CLUSTER\"" >> $CONFIG_FILE
echo "namespace: \"/postgresql-common/\"" >> $CONFIG_FILE
echo "name: \"$HOSTNAME\"" >> $CONFIG_FILE
echo "" >> $CONFIG_FILE
# add DCS configuration
cat /etc/patroni/dcs.yml >> $CONFIG_FILE
echo "" >> $CONFIG_FILE
# add remaining patroni configuration from template
cat /etc/patroni/config.yml.in | \
sed -e s/@VERSION@/${VERSION}/g \
-e s/@CLUSTER@/${CLUSTER}/g \
-e s/@HOSTIP@/${HOSTIP}/g \
-e s/@PORT@/${PORT}/g \
cat /etc/patroni/config.yml.in | \
sed -e "s/@VERSION@/${VERSION}/g" \
-e "s/@CLUSTER@/${CLUSTER}/g" \
-e "s/@HOSTNAME@/${HOSTNAME}/g" \
-e "s/@HOSTIP@/${HOSTIP}/g" \
-e "s/@PORT@/${PORT}/g" \
-e "s/@DCS_CONFIG@/${DCS_CONFIG}/g" \
>> $CONFIG_FILE
# Set permissions