1
0
mirror of https://github.com/docker-library/postgres.git synced 2025-07-29 21:41:20 +03:00

Refactor listen_addresses to be set in the sample file, and make the sample file easier to overwrite

This commit is contained in:
Tianon Gravi
2016-02-26 10:55:10 -08:00
parent ec5ce80ca9
commit 41e7a62fb4
2 changed files with 8 additions and 5 deletions

View File

@ -36,6 +36,11 @@ RUN apt-get update \
postgresql-contrib-$PG_MAJOR=$PG_VERSION \ postgresql-contrib-$PG_MAJOR=$PG_VERSION \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# make the sample config easier to munge (and "correct by default")
RUN mv -v /usr/share/postgresql/$PG_MAJOR/postgresql.conf.sample /usr/share/postgresql/ \
&& ln -sv ../postgresql.conf.sample /usr/share/postgresql/$PG_MAJOR/ \
&& sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/share/postgresql/postgresql.conf.sample
RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql
ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH

View File

@ -1,10 +1,9 @@
#!/bin/bash #!/bin/bash
set -e set -e
set_listen_addresses() { if [ "${1:0:1}" = '-' ]; then
sedEscapedValue="$(echo "$1" | sed 's/[\/&]/\\&/g')" set -- postgres "$@"
sed -ri "s/^#?(listen_addresses\s*=\s*)\S+/\1'$sedEscapedValue'/" "$PGDATA/postgresql.conf" fi
}
if [ "$1" = 'postgres' ]; then if [ "$1" = 'postgres' ]; then
mkdir -p "$PGDATA" mkdir -p "$PGDATA"
@ -88,7 +87,6 @@ if [ "$1" = 'postgres' ]; then
done done
gosu postgres pg_ctl -D "$PGDATA" -m fast -w stop gosu postgres pg_ctl -D "$PGDATA" -m fast -w stop
set_listen_addresses '*'
echo echo
echo 'PostgreSQL init process complete; ready for start up.' echo 'PostgreSQL init process complete; ready for start up.'