diff --git a/9.2/alpine/docker-entrypoint.sh b/9.2/alpine/docker-entrypoint.sh index 0ec0bdd54e..0b0af0d7e0 100755 --- a/9.2/alpine/docker-entrypoint.sh +++ b/9.2/alpine/docker-entrypoint.sh @@ -37,6 +37,13 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then chown -R postgres /var/run/postgresql chmod g+s /var/run/postgresql + # Create the transaction log directory before initdb is run (below) so the directory is owned by the correct user + if [ "$POSTGRES_INITDB_XLOGDIR" ]; then + mkdir -p "$POSTGRES_INITDB_XLOGDIR" + chown -R postgres "$POSTGRES_INITDB_XLOGDIR" + chmod 700 "$POSTGRES_INITDB_XLOGDIR" + fi + exec su-exec postgres "$BASH_SOURCE" "$@" fi @@ -48,6 +55,9 @@ if [ "$1" = 'postgres' ]; then # look specifically for PG_VERSION, as it is expected in the DB dir if [ ! -s "$PGDATA/PG_VERSION" ]; then file_env 'POSTGRES_INITDB_ARGS' + if [ "$POSTGRES_INITDB_XLOGDIR" ]; then + export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR" + fi eval "initdb --username=postgres $POSTGRES_INITDB_ARGS" # check password first so we can output the warning before postgres diff --git a/9.2/docker-entrypoint.sh b/9.2/docker-entrypoint.sh index 66ea0f1d94..6b18e8b1a5 100755 --- a/9.2/docker-entrypoint.sh +++ b/9.2/docker-entrypoint.sh @@ -37,6 +37,13 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then chown -R postgres /var/run/postgresql chmod g+s /var/run/postgresql + # Create the transaction log directory before initdb is run (below) so the directory is owned by the correct user + if [ "$POSTGRES_INITDB_XLOGDIR" ]; then + mkdir -p "$POSTGRES_INITDB_XLOGDIR" + chown -R postgres "$POSTGRES_INITDB_XLOGDIR" + chmod 700 "$POSTGRES_INITDB_XLOGDIR" + fi + exec gosu postgres "$BASH_SOURCE" "$@" fi @@ -48,6 +55,9 @@ if [ "$1" = 'postgres' ]; then # look specifically for PG_VERSION, as it is expected in the DB dir if [ ! -s "$PGDATA/PG_VERSION" ]; then file_env 'POSTGRES_INITDB_ARGS' + if [ "$POSTGRES_INITDB_XLOGDIR" ]; then + export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR" + fi eval "initdb --username=postgres $POSTGRES_INITDB_ARGS" # check password first so we can output the warning before postgres diff --git a/9.3/alpine/docker-entrypoint.sh b/9.3/alpine/docker-entrypoint.sh index 0ec0bdd54e..0b0af0d7e0 100755 --- a/9.3/alpine/docker-entrypoint.sh +++ b/9.3/alpine/docker-entrypoint.sh @@ -37,6 +37,13 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then chown -R postgres /var/run/postgresql chmod g+s /var/run/postgresql + # Create the transaction log directory before initdb is run (below) so the directory is owned by the correct user + if [ "$POSTGRES_INITDB_XLOGDIR" ]; then + mkdir -p "$POSTGRES_INITDB_XLOGDIR" + chown -R postgres "$POSTGRES_INITDB_XLOGDIR" + chmod 700 "$POSTGRES_INITDB_XLOGDIR" + fi + exec su-exec postgres "$BASH_SOURCE" "$@" fi @@ -48,6 +55,9 @@ if [ "$1" = 'postgres' ]; then # look specifically for PG_VERSION, as it is expected in the DB dir if [ ! -s "$PGDATA/PG_VERSION" ]; then file_env 'POSTGRES_INITDB_ARGS' + if [ "$POSTGRES_INITDB_XLOGDIR" ]; then + export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR" + fi eval "initdb --username=postgres $POSTGRES_INITDB_ARGS" # check password first so we can output the warning before postgres diff --git a/9.3/docker-entrypoint.sh b/9.3/docker-entrypoint.sh index 66ea0f1d94..6b18e8b1a5 100755 --- a/9.3/docker-entrypoint.sh +++ b/9.3/docker-entrypoint.sh @@ -37,6 +37,13 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then chown -R postgres /var/run/postgresql chmod g+s /var/run/postgresql + # Create the transaction log directory before initdb is run (below) so the directory is owned by the correct user + if [ "$POSTGRES_INITDB_XLOGDIR" ]; then + mkdir -p "$POSTGRES_INITDB_XLOGDIR" + chown -R postgres "$POSTGRES_INITDB_XLOGDIR" + chmod 700 "$POSTGRES_INITDB_XLOGDIR" + fi + exec gosu postgres "$BASH_SOURCE" "$@" fi @@ -48,6 +55,9 @@ if [ "$1" = 'postgres' ]; then # look specifically for PG_VERSION, as it is expected in the DB dir if [ ! -s "$PGDATA/PG_VERSION" ]; then file_env 'POSTGRES_INITDB_ARGS' + if [ "$POSTGRES_INITDB_XLOGDIR" ]; then + export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR" + fi eval "initdb --username=postgres $POSTGRES_INITDB_ARGS" # check password first so we can output the warning before postgres diff --git a/9.4/alpine/docker-entrypoint.sh b/9.4/alpine/docker-entrypoint.sh index 0ec0bdd54e..0b0af0d7e0 100755 --- a/9.4/alpine/docker-entrypoint.sh +++ b/9.4/alpine/docker-entrypoint.sh @@ -37,6 +37,13 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then chown -R postgres /var/run/postgresql chmod g+s /var/run/postgresql + # Create the transaction log directory before initdb is run (below) so the directory is owned by the correct user + if [ "$POSTGRES_INITDB_XLOGDIR" ]; then + mkdir -p "$POSTGRES_INITDB_XLOGDIR" + chown -R postgres "$POSTGRES_INITDB_XLOGDIR" + chmod 700 "$POSTGRES_INITDB_XLOGDIR" + fi + exec su-exec postgres "$BASH_SOURCE" "$@" fi @@ -48,6 +55,9 @@ if [ "$1" = 'postgres' ]; then # look specifically for PG_VERSION, as it is expected in the DB dir if [ ! -s "$PGDATA/PG_VERSION" ]; then file_env 'POSTGRES_INITDB_ARGS' + if [ "$POSTGRES_INITDB_XLOGDIR" ]; then + export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR" + fi eval "initdb --username=postgres $POSTGRES_INITDB_ARGS" # check password first so we can output the warning before postgres diff --git a/9.4/docker-entrypoint.sh b/9.4/docker-entrypoint.sh index 66ea0f1d94..6b18e8b1a5 100755 --- a/9.4/docker-entrypoint.sh +++ b/9.4/docker-entrypoint.sh @@ -37,6 +37,13 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then chown -R postgres /var/run/postgresql chmod g+s /var/run/postgresql + # Create the transaction log directory before initdb is run (below) so the directory is owned by the correct user + if [ "$POSTGRES_INITDB_XLOGDIR" ]; then + mkdir -p "$POSTGRES_INITDB_XLOGDIR" + chown -R postgres "$POSTGRES_INITDB_XLOGDIR" + chmod 700 "$POSTGRES_INITDB_XLOGDIR" + fi + exec gosu postgres "$BASH_SOURCE" "$@" fi @@ -48,6 +55,9 @@ if [ "$1" = 'postgres' ]; then # look specifically for PG_VERSION, as it is expected in the DB dir if [ ! -s "$PGDATA/PG_VERSION" ]; then file_env 'POSTGRES_INITDB_ARGS' + if [ "$POSTGRES_INITDB_XLOGDIR" ]; then + export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR" + fi eval "initdb --username=postgres $POSTGRES_INITDB_ARGS" # check password first so we can output the warning before postgres diff --git a/9.5/alpine/docker-entrypoint.sh b/9.5/alpine/docker-entrypoint.sh index 0ec0bdd54e..0b0af0d7e0 100755 --- a/9.5/alpine/docker-entrypoint.sh +++ b/9.5/alpine/docker-entrypoint.sh @@ -37,6 +37,13 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then chown -R postgres /var/run/postgresql chmod g+s /var/run/postgresql + # Create the transaction log directory before initdb is run (below) so the directory is owned by the correct user + if [ "$POSTGRES_INITDB_XLOGDIR" ]; then + mkdir -p "$POSTGRES_INITDB_XLOGDIR" + chown -R postgres "$POSTGRES_INITDB_XLOGDIR" + chmod 700 "$POSTGRES_INITDB_XLOGDIR" + fi + exec su-exec postgres "$BASH_SOURCE" "$@" fi @@ -48,6 +55,9 @@ if [ "$1" = 'postgres' ]; then # look specifically for PG_VERSION, as it is expected in the DB dir if [ ! -s "$PGDATA/PG_VERSION" ]; then file_env 'POSTGRES_INITDB_ARGS' + if [ "$POSTGRES_INITDB_XLOGDIR" ]; then + export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR" + fi eval "initdb --username=postgres $POSTGRES_INITDB_ARGS" # check password first so we can output the warning before postgres diff --git a/9.5/docker-entrypoint.sh b/9.5/docker-entrypoint.sh index 66ea0f1d94..6b18e8b1a5 100755 --- a/9.5/docker-entrypoint.sh +++ b/9.5/docker-entrypoint.sh @@ -37,6 +37,13 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then chown -R postgres /var/run/postgresql chmod g+s /var/run/postgresql + # Create the transaction log directory before initdb is run (below) so the directory is owned by the correct user + if [ "$POSTGRES_INITDB_XLOGDIR" ]; then + mkdir -p "$POSTGRES_INITDB_XLOGDIR" + chown -R postgres "$POSTGRES_INITDB_XLOGDIR" + chmod 700 "$POSTGRES_INITDB_XLOGDIR" + fi + exec gosu postgres "$BASH_SOURCE" "$@" fi @@ -48,6 +55,9 @@ if [ "$1" = 'postgres' ]; then # look specifically for PG_VERSION, as it is expected in the DB dir if [ ! -s "$PGDATA/PG_VERSION" ]; then file_env 'POSTGRES_INITDB_ARGS' + if [ "$POSTGRES_INITDB_XLOGDIR" ]; then + export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR" + fi eval "initdb --username=postgres $POSTGRES_INITDB_ARGS" # check password first so we can output the warning before postgres diff --git a/9.6/alpine/docker-entrypoint.sh b/9.6/alpine/docker-entrypoint.sh index 0ec0bdd54e..0b0af0d7e0 100755 --- a/9.6/alpine/docker-entrypoint.sh +++ b/9.6/alpine/docker-entrypoint.sh @@ -37,6 +37,13 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then chown -R postgres /var/run/postgresql chmod g+s /var/run/postgresql + # Create the transaction log directory before initdb is run (below) so the directory is owned by the correct user + if [ "$POSTGRES_INITDB_XLOGDIR" ]; then + mkdir -p "$POSTGRES_INITDB_XLOGDIR" + chown -R postgres "$POSTGRES_INITDB_XLOGDIR" + chmod 700 "$POSTGRES_INITDB_XLOGDIR" + fi + exec su-exec postgres "$BASH_SOURCE" "$@" fi @@ -48,6 +55,9 @@ if [ "$1" = 'postgres' ]; then # look specifically for PG_VERSION, as it is expected in the DB dir if [ ! -s "$PGDATA/PG_VERSION" ]; then file_env 'POSTGRES_INITDB_ARGS' + if [ "$POSTGRES_INITDB_XLOGDIR" ]; then + export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR" + fi eval "initdb --username=postgres $POSTGRES_INITDB_ARGS" # check password first so we can output the warning before postgres diff --git a/9.6/docker-entrypoint.sh b/9.6/docker-entrypoint.sh index 66ea0f1d94..6b18e8b1a5 100755 --- a/9.6/docker-entrypoint.sh +++ b/9.6/docker-entrypoint.sh @@ -37,6 +37,13 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then chown -R postgres /var/run/postgresql chmod g+s /var/run/postgresql + # Create the transaction log directory before initdb is run (below) so the directory is owned by the correct user + if [ "$POSTGRES_INITDB_XLOGDIR" ]; then + mkdir -p "$POSTGRES_INITDB_XLOGDIR" + chown -R postgres "$POSTGRES_INITDB_XLOGDIR" + chmod 700 "$POSTGRES_INITDB_XLOGDIR" + fi + exec gosu postgres "$BASH_SOURCE" "$@" fi @@ -48,6 +55,9 @@ if [ "$1" = 'postgres' ]; then # look specifically for PG_VERSION, as it is expected in the DB dir if [ ! -s "$PGDATA/PG_VERSION" ]; then file_env 'POSTGRES_INITDB_ARGS' + if [ "$POSTGRES_INITDB_XLOGDIR" ]; then + export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR" + fi eval "initdb --username=postgres $POSTGRES_INITDB_ARGS" # check password first so we can output the warning before postgres diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 66ea0f1d94..6b18e8b1a5 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -37,6 +37,13 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then chown -R postgres /var/run/postgresql chmod g+s /var/run/postgresql + # Create the transaction log directory before initdb is run (below) so the directory is owned by the correct user + if [ "$POSTGRES_INITDB_XLOGDIR" ]; then + mkdir -p "$POSTGRES_INITDB_XLOGDIR" + chown -R postgres "$POSTGRES_INITDB_XLOGDIR" + chmod 700 "$POSTGRES_INITDB_XLOGDIR" + fi + exec gosu postgres "$BASH_SOURCE" "$@" fi @@ -48,6 +55,9 @@ if [ "$1" = 'postgres' ]; then # look specifically for PG_VERSION, as it is expected in the DB dir if [ ! -s "$PGDATA/PG_VERSION" ]; then file_env 'POSTGRES_INITDB_ARGS' + if [ "$POSTGRES_INITDB_XLOGDIR" ]; then + export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR" + fi eval "initdb --username=postgres $POSTGRES_INITDB_ARGS" # check password first so we can output the warning before postgres