#!/bin/bash
# Configure PostgreSQL to accept password authentication from TCP connections
# This file will be executed by docker-entrypoint.sh

# First, remove any existing SCRAM rules that would take precedence
sed -i '/^host.*scram-sha-256$/d' /var/lib/postgresql/data/pg_hba.conf

# Append password auth rules for TCP before the replication entries
sed -i '/^host.*replication/i host    all             all             127.0.0.1/32            password' /var/lib/postgresql/data/pg_hba.conf
sed -i '/^host.*replication/i host    all             all             0.0.0.0/0               password' /var/lib/postgresql/data/pg_hba.conf
