* debian/config.yml.in: Make base data directory a template variable

@DATADIR_BASE@.
  * debian/pg_createconfig_patroni: Use data_directory setting from
    /etc/postgresql-common/createcluster.conf as DATADIR_BASE if set.
This commit is contained in:
Michael Banck 2021-01-22 10:09:46 +01:00
parent ae3072dce0
commit 932a1911a8
3 changed files with 14 additions and 1 deletions

4
debian/changelog vendored
View file

@ -5,6 +5,10 @@ patroni (2.0.1-3) UNRELEASED; urgency=medium
be misleading.
* debian/pg_clonecluster_patroni: After pg_dropcluster, remove
postgresql.base.conf as well.
* debian/config.yml.in: Make base data directory a template variable
@DATADIR_BASE@.
* debian/pg_createconfig_patroni: Use data_directory setting from
/etc/postgresql-common/createcluster.conf as DATADIR_BASE if set.
-- Debian PostgreSQL Maintainers <team+postgresql@tracker.debian.org> Thu, 10 Dec 2020 13:33:54 +0100

View file

@ -97,7 +97,7 @@ postgresql:
listen: "*:@PORT@"
connect_address: @HOSTIP@:@PORT@
use_unix_socket: true
data_dir: /var/lib/postgresql/@VERSION@/@CLUSTER@
data_dir: @DATADIR_BASE@/@VERSION@/@CLUSTER@
bin_dir: /usr/lib/postgresql/@VERSION@/bin
config_dir: /etc/postgresql/@VERSION@/@CLUSTER@
pgpass: /var/lib/postgresql/@VERSION@-@CLUSTER@.pgpass

View file

@ -91,6 +91,14 @@ fi
# Postgres port. 2576 is 8008 - 5432.
API_PORT=$((2576+$PORT))
# set base data directory
if [ -f /etc/postgresql-common/createcluster.conf ]; then
DATADIR_BASE=$(grep ^data_directory /etc/postgresql-common/createcluster.conf | sed -e 's/^[^\/]*\//\//g' -e 's/\%.*//' -e 's/\/$//')
fi
if [ -z "${DATADIR_BASE}" ]; then
DATADIR_BASE=/var/lib/postgresql
fi
# check DCS configuration
if [ ! -f /etc/patroni/dcs.yml ]; then
echo "DCS not configured yet, edit /etc/patroni/dcs.yml"
@ -204,6 +212,7 @@ cat /etc/patroni/config.yml.in | \
-e "s/@HOSTNAME@/${HOSTNAME}/g" \
-e "s/@HOSTIP@/${HOSTIP}/g" \
-e "s/@LISTEN_VIP@/${LISTEN_VIP}/g" \
-e "s#@DATADIR_BASE@#${DATADIR_BASE}#g" \
-e "s#@NETWORK@#${NETWORK}#g" \
-e "s/@API_PORT@/${API_PORT}/g" \
-e "s/@PORT@/${PORT}/g" \