add pgpool user

This commit is contained in:
Bernhard Radermacher
2026-02-24 10:04:32 +01:00
parent 1d608f9f99
commit 8799f67db6
2 changed files with 13 additions and 23 deletions

View File

@@ -132,17 +132,10 @@ if [ "$(id -u)" = '0' ]; then
exec gosu postgres "$BASH_SOURCE"
fi
# convert to lowercase
REPMGR_NODE_ROLE="${REPMGR_NODE_ROLE,,}"
if [[ ! -s "$PGDATA/PG_VERSION" ]]; then
repmgr_setup_conf
if [[ -n $REPMGR_UPSTREAM ]] && [[ -z $REPMGR_NODE_ROLE ]]; then
REPMGR_NODE_ROLE="standby"
fi
if [[ $REPMGR_NODE_ROLE != "standby" ]]; then
if [[ -z $REPMGR_UPSTREAM ]]; then
docker_init_database_dir
pg_setup_conf
pg_setup_hba_conf
@@ -154,7 +147,15 @@ if [[ ! -s "$PGDATA/PG_VERSION" ]]; then
psql -c "CREATE DATABASE repmgr WITH OWNER repmgr;"
psql -c 'ALTER USER repmgr SET search_path TO repmgr, "$user", public;'
if [[ -n $PGPOOL_PASSWORD ]]; then
psql -c "CREATE USER pgpool WITH ENCRYPTED PASSWORD '${PGPOOL_PASSWORD}';"
fi
unset PGPASSWORD
/usr/lib/postgresql/15/bin/repmgr -f /etc/repmgr/repmgr.conf primary register
else
until /usr/lib/postgresql/15/bin/repmgr -h $REPMGR_UPSTREAM -U repmgr -f /etc/repmgr/repmgr.conf standby clone --dry-run &> /dev/null
do
@@ -164,20 +165,9 @@ if [[ ! -s "$PGDATA/PG_VERSION" ]]; then
echo "Upstream host found..."
/usr/lib/postgresql/15/bin/repmgr -h $REPMGR_UPSTREAM -U repmgr -f /etc/repmgr/repmgr.conf standby clone
docker_temp_server_start
fi
/usr/lib/postgresql/15/bin/repmgr -f /etc/repmgr/repmgr.conf standby register --force
case "$REPMGR_NODE_ROLE" in
standby )
/usr/lib/postgresql/15/bin/repmgr -f /etc/repmgr/repmgr.conf standby register --force
;;
witness )
echo "Witness Server not supported for this configuration!"
exit 100
;;
* )
/usr/lib/postgresql/15/bin/repmgr -f /etc/repmgr/repmgr.conf primary register
;;
esac
fi
docker_temp_server_stop
fi