Skip to content

Commit 86d405d

Browse files
authored
Merge pull request itsmechlark#37 from slonopotamus/patch-2
fix(postgresql) Allow connections after container is recreated
2 parents f929a89 + b801aaf commit 86d405d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/postgresql/install.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,16 @@ set -e
6161
6262
version_major=$(psql --version | sed -z "s/psql (PostgreSQL) //g" | grep -Eo -m 1 "^([0-9]+)" | sed -z "s/-//g")
6363
64+
echo "listen_addresses = '*'" >> /etc/postgresql/${version_major}/main/postgresql.conf \
65+
&& echo "data_directory = '$PGDATA'" >> /etc/postgresql/${version_major}/main/postgresql.conf \
66+
&& echo "host all all 0.0.0.0/0 trust" > /etc/postgresql/${version_major}/main/pg_hba.conf \
67+
&& echo "host all all ::/0 trust" >> /etc/postgresql/${version_major}/main/pg_hba.conf \
68+
&& echo "host all all ::1/128 trust" >> /etc/postgresql/${version_major}/main/pg_hba.conf
69+
6470
if [ ! -f "$PGDATA/PG_VERSION" ]; then
6571
echo "Initializing PostgreSQL database..."
6672
chown -R postgres:postgres $PGDATA \
6773
&& chmod 0750 $PGDATA \
68-
&& echo "listen_addresses = '*'" >> /etc/postgresql/${version_major}/main/postgresql.conf \
69-
&& echo "data_directory = '$PGDATA'" >> /etc/postgresql/${version_major}/main/postgresql.conf \
70-
&& echo "host all all 0.0.0.0/0 trust" > /etc/postgresql/${version_major}/main/pg_hba.conf \
71-
&& echo "host all all ::/0 trust" >> /etc/postgresql/${version_major}/main/pg_hba.conf \
72-
&& echo "host all all ::1/128 trust" >> /etc/postgresql/${version_major}/main/pg_hba.conf \
7374
&& sudo -H -u postgres sh -c "/usr/lib/postgresql/${version_major}/bin/initdb -D $PGDATA --auth-local trust --auth-host scram-sha-256"
7475
else
7576
echo "PostgreSQL database already initialized, skipping initialization"

0 commit comments

Comments
 (0)