Skip to content

Commit 913bc48

Browse files
committed
Update order to match other blocks and move "--xlogdir" handling down to where it'll be invoked regardless of our "root" status
1 parent 89530f6 commit 913bc48

11 files changed

+44
-33
lines changed

9.2/alpine/docker-entrypoint.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then
3838
chmod g+s /var/run/postgresql
3939

4040
# Create the transaction log directory before initdb is run (below) so the directory is owned by the correct user
41-
file_env 'POSTGRES_INITDB_XLOGDIR'
4241
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
4342
mkdir -p "$POSTGRES_INITDB_XLOGDIR"
44-
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
4543
chown -R postgres "$POSTGRES_INITDB_XLOGDIR"
46-
export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR"
44+
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
4745
fi
4846

4947
exec su-exec postgres "$BASH_SOURCE" "$@"
@@ -57,6 +55,9 @@ if [ "$1" = 'postgres' ]; then
5755
# look specifically for PG_VERSION, as it is expected in the DB dir
5856
if [ ! -s "$PGDATA/PG_VERSION" ]; then
5957
file_env 'POSTGRES_INITDB_ARGS'
58+
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
59+
export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR"
60+
fi
6061
eval "initdb --username=postgres $POSTGRES_INITDB_ARGS"
6162

6263
# check password first so we can output the warning before postgres

9.2/docker-entrypoint.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then
3838
chmod g+s /var/run/postgresql
3939

4040
# Create the transaction log directory before initdb is run (below) so the directory is owned by the correct user
41-
file_env 'POSTGRES_INITDB_XLOGDIR'
4241
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
4342
mkdir -p "$POSTGRES_INITDB_XLOGDIR"
44-
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
4543
chown -R postgres "$POSTGRES_INITDB_XLOGDIR"
46-
export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR"
44+
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
4745
fi
4846

4947
exec gosu postgres "$BASH_SOURCE" "$@"
@@ -57,6 +55,9 @@ if [ "$1" = 'postgres' ]; then
5755
# look specifically for PG_VERSION, as it is expected in the DB dir
5856
if [ ! -s "$PGDATA/PG_VERSION" ]; then
5957
file_env 'POSTGRES_INITDB_ARGS'
58+
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
59+
export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR"
60+
fi
6061
eval "initdb --username=postgres $POSTGRES_INITDB_ARGS"
6162

6263
# check password first so we can output the warning before postgres

9.3/alpine/docker-entrypoint.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then
3838
chmod g+s /var/run/postgresql
3939

4040
# Create the transaction log directory before initdb is run (below) so the directory is owned by the correct user
41-
file_env 'POSTGRES_INITDB_XLOGDIR'
4241
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
4342
mkdir -p "$POSTGRES_INITDB_XLOGDIR"
44-
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
4543
chown -R postgres "$POSTGRES_INITDB_XLOGDIR"
46-
export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR"
44+
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
4745
fi
4846

4947
exec su-exec postgres "$BASH_SOURCE" "$@"
@@ -57,6 +55,9 @@ if [ "$1" = 'postgres' ]; then
5755
# look specifically for PG_VERSION, as it is expected in the DB dir
5856
if [ ! -s "$PGDATA/PG_VERSION" ]; then
5957
file_env 'POSTGRES_INITDB_ARGS'
58+
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
59+
export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR"
60+
fi
6061
eval "initdb --username=postgres $POSTGRES_INITDB_ARGS"
6162

6263
# check password first so we can output the warning before postgres

9.3/docker-entrypoint.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then
3838
chmod g+s /var/run/postgresql
3939

4040
# Create the transaction log directory before initdb is run (below) so the directory is owned by the correct user
41-
file_env 'POSTGRES_INITDB_XLOGDIR'
4241
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
4342
mkdir -p "$POSTGRES_INITDB_XLOGDIR"
44-
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
4543
chown -R postgres "$POSTGRES_INITDB_XLOGDIR"
46-
export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR"
44+
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
4745
fi
4846

4947
exec gosu postgres "$BASH_SOURCE" "$@"
@@ -57,6 +55,9 @@ if [ "$1" = 'postgres' ]; then
5755
# look specifically for PG_VERSION, as it is expected in the DB dir
5856
if [ ! -s "$PGDATA/PG_VERSION" ]; then
5957
file_env 'POSTGRES_INITDB_ARGS'
58+
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
59+
export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR"
60+
fi
6061
eval "initdb --username=postgres $POSTGRES_INITDB_ARGS"
6162

6263
# check password first so we can output the warning before postgres

9.4/alpine/docker-entrypoint.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then
3838
chmod g+s /var/run/postgresql
3939

4040
# Create the transaction log directory before initdb is run (below) so the directory is owned by the correct user
41-
file_env 'POSTGRES_INITDB_XLOGDIR'
4241
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
4342
mkdir -p "$POSTGRES_INITDB_XLOGDIR"
44-
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
4543
chown -R postgres "$POSTGRES_INITDB_XLOGDIR"
46-
export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR"
44+
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
4745
fi
4846

4947
exec su-exec postgres "$BASH_SOURCE" "$@"
@@ -57,6 +55,9 @@ if [ "$1" = 'postgres' ]; then
5755
# look specifically for PG_VERSION, as it is expected in the DB dir
5856
if [ ! -s "$PGDATA/PG_VERSION" ]; then
5957
file_env 'POSTGRES_INITDB_ARGS'
58+
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
59+
export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR"
60+
fi
6061
eval "initdb --username=postgres $POSTGRES_INITDB_ARGS"
6162

6263
# check password first so we can output the warning before postgres

9.4/docker-entrypoint.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then
3838
chmod g+s /var/run/postgresql
3939

4040
# Create the transaction log directory before initdb is run (below) so the directory is owned by the correct user
41-
file_env 'POSTGRES_INITDB_XLOGDIR'
4241
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
4342
mkdir -p "$POSTGRES_INITDB_XLOGDIR"
44-
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
4543
chown -R postgres "$POSTGRES_INITDB_XLOGDIR"
46-
export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR"
44+
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
4745
fi
4846

4947
exec gosu postgres "$BASH_SOURCE" "$@"
@@ -57,6 +55,9 @@ if [ "$1" = 'postgres' ]; then
5755
# look specifically for PG_VERSION, as it is expected in the DB dir
5856
if [ ! -s "$PGDATA/PG_VERSION" ]; then
5957
file_env 'POSTGRES_INITDB_ARGS'
58+
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
59+
export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR"
60+
fi
6061
eval "initdb --username=postgres $POSTGRES_INITDB_ARGS"
6162

6263
# check password first so we can output the warning before postgres

9.5/alpine/docker-entrypoint.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then
3838
chmod g+s /var/run/postgresql
3939

4040
# Create the transaction log directory before initdb is run (below) so the directory is owned by the correct user
41-
file_env 'POSTGRES_INITDB_XLOGDIR'
4241
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
4342
mkdir -p "$POSTGRES_INITDB_XLOGDIR"
44-
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
4543
chown -R postgres "$POSTGRES_INITDB_XLOGDIR"
46-
export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR"
44+
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
4745
fi
4846

4947
exec su-exec postgres "$BASH_SOURCE" "$@"
@@ -57,6 +55,9 @@ if [ "$1" = 'postgres' ]; then
5755
# look specifically for PG_VERSION, as it is expected in the DB dir
5856
if [ ! -s "$PGDATA/PG_VERSION" ]; then
5957
file_env 'POSTGRES_INITDB_ARGS'
58+
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
59+
export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR"
60+
fi
6061
eval "initdb --username=postgres $POSTGRES_INITDB_ARGS"
6162

6263
# check password first so we can output the warning before postgres

9.5/docker-entrypoint.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then
3838
chmod g+s /var/run/postgresql
3939

4040
# Create the transaction log directory before initdb is run (below) so the directory is owned by the correct user
41-
file_env 'POSTGRES_INITDB_XLOGDIR'
4241
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
4342
mkdir -p "$POSTGRES_INITDB_XLOGDIR"
44-
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
4543
chown -R postgres "$POSTGRES_INITDB_XLOGDIR"
46-
export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR"
44+
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
4745
fi
4846

4947
exec gosu postgres "$BASH_SOURCE" "$@"
@@ -57,6 +55,9 @@ if [ "$1" = 'postgres' ]; then
5755
# look specifically for PG_VERSION, as it is expected in the DB dir
5856
if [ ! -s "$PGDATA/PG_VERSION" ]; then
5957
file_env 'POSTGRES_INITDB_ARGS'
58+
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
59+
export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR"
60+
fi
6061
eval "initdb --username=postgres $POSTGRES_INITDB_ARGS"
6162

6263
# check password first so we can output the warning before postgres

9.6/alpine/docker-entrypoint.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then
3838
chmod g+s /var/run/postgresql
3939

4040
# Create the transaction log directory before initdb is run (below) so the directory is owned by the correct user
41-
file_env 'POSTGRES_INITDB_XLOGDIR'
4241
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
4342
mkdir -p "$POSTGRES_INITDB_XLOGDIR"
44-
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
4543
chown -R postgres "$POSTGRES_INITDB_XLOGDIR"
46-
export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR"
44+
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
4745
fi
4846

4947
exec su-exec postgres "$BASH_SOURCE" "$@"
@@ -57,6 +55,9 @@ if [ "$1" = 'postgres' ]; then
5755
# look specifically for PG_VERSION, as it is expected in the DB dir
5856
if [ ! -s "$PGDATA/PG_VERSION" ]; then
5957
file_env 'POSTGRES_INITDB_ARGS'
58+
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
59+
export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR"
60+
fi
6061
eval "initdb --username=postgres $POSTGRES_INITDB_ARGS"
6162

6263
# check password first so we can output the warning before postgres

9.6/docker-entrypoint.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then
3838
chmod g+s /var/run/postgresql
3939

4040
# Create the transaction log directory before initdb is run (below) so the directory is owned by the correct user
41-
file_env 'POSTGRES_INITDB_XLOGDIR'
4241
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
4342
mkdir -p "$POSTGRES_INITDB_XLOGDIR"
44-
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
4543
chown -R postgres "$POSTGRES_INITDB_XLOGDIR"
46-
export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR"
44+
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
4745
fi
4846

4947
exec gosu postgres "$BASH_SOURCE" "$@"
@@ -57,6 +55,9 @@ if [ "$1" = 'postgres' ]; then
5755
# look specifically for PG_VERSION, as it is expected in the DB dir
5856
if [ ! -s "$PGDATA/PG_VERSION" ]; then
5957
file_env 'POSTGRES_INITDB_ARGS'
58+
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
59+
export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR"
60+
fi
6061
eval "initdb --username=postgres $POSTGRES_INITDB_ARGS"
6162

6263
# check password first so we can output the warning before postgres

docker-entrypoint.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then
3838
chmod g+s /var/run/postgresql
3939

4040
# Create the transaction log directory before initdb is run (below) so the directory is owned by the correct user
41-
file_env 'POSTGRES_INITDB_XLOGDIR'
4241
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
4342
mkdir -p "$POSTGRES_INITDB_XLOGDIR"
44-
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
4543
chown -R postgres "$POSTGRES_INITDB_XLOGDIR"
46-
export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR"
44+
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
4745
fi
4846

4947
exec gosu postgres "$BASH_SOURCE" "$@"
@@ -57,6 +55,9 @@ if [ "$1" = 'postgres' ]; then
5755
# look specifically for PG_VERSION, as it is expected in the DB dir
5856
if [ ! -s "$PGDATA/PG_VERSION" ]; then
5957
file_env 'POSTGRES_INITDB_ARGS'
58+
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
59+
export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR"
60+
fi
6061
eval "initdb --username=postgres $POSTGRES_INITDB_ARGS"
6162

6263
# check password first so we can output the warning before postgres

0 commit comments

Comments
 (0)