Skip to content

Commit 8fada98

Browse files
committed
Fixes from tianon's review
1 parent 7c84645 commit 8fada98

13 files changed

+78
-91
lines changed

10/alpine/docker-entrypoint.sh

+6-7
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ _is_sourced() {
3434

3535
# used to create initial posgres directories and if run as root, ensure ownership to the "postgres" user
3636
docker_create_db_directories() {
37-
local user="$(id -u)"
37+
local user; user="$(id -u)"
3838

3939
mkdir -p "$PGDATA"
4040
chmod 700 "$PGDATA"
@@ -46,7 +46,9 @@ docker_create_db_directories() {
4646
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
4747
if [ "$POSTGRES_INITDB_WALDIR" ]; then
4848
mkdir -p "$POSTGRES_INITDB_WALDIR"
49-
[ "$user" = '0' ] && find "$POSTGRES_INITDB_WALDIR" \! -user postgres - exec chown postgres '{}' +
49+
if [ "$user" = '0' ]; then
50+
find "$POSTGRES_INITDB_WALDIR" \! -user postgres -exec chown postgres '{}' +
51+
fi
5052
chmod 700 "$POSTGRES_INITDB_WALDIR"
5153
fi
5254

@@ -193,10 +195,8 @@ docker_setup_env() {
193195

194196
# append md5 or trust auth to pg_hba.conf based on existence of POSTGRES_PASSWORD
195197
pg_setup_hba_conf() {
196-
local authMethod
197-
if [ "$POSTGRES_PASSWORD" ]; then
198-
authMethod='md5'
199-
else
198+
local authMethod='md5'
199+
if [ -z "$POSTGRES_PASSWORD" ]; then
200200
authMethod='trust'
201201
fi
202202

@@ -232,7 +232,6 @@ _main() {
232232
set -- postgres "$@"
233233
fi
234234

235-
236235
if [ "$1" = 'postgres' ]; then
237236
docker_setup_env
238237
# setup data directories and permissions (when run as root)

10/docker-entrypoint.sh

+6-7
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ _is_sourced() {
3434

3535
# used to create initial posgres directories and if run as root, ensure ownership to the "postgres" user
3636
docker_create_db_directories() {
37-
local user="$(id -u)"
37+
local user; user="$(id -u)"
3838

3939
mkdir -p "$PGDATA"
4040
chmod 700 "$PGDATA"
@@ -46,7 +46,9 @@ docker_create_db_directories() {
4646
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
4747
if [ "$POSTGRES_INITDB_WALDIR" ]; then
4848
mkdir -p "$POSTGRES_INITDB_WALDIR"
49-
[ "$user" = '0' ] && find "$POSTGRES_INITDB_WALDIR" \! -user postgres - exec chown postgres '{}' +
49+
if [ "$user" = '0' ]; then
50+
find "$POSTGRES_INITDB_WALDIR" \! -user postgres -exec chown postgres '{}' +
51+
fi
5052
chmod 700 "$POSTGRES_INITDB_WALDIR"
5153
fi
5254

@@ -193,10 +195,8 @@ docker_setup_env() {
193195

194196
# append md5 or trust auth to pg_hba.conf based on existence of POSTGRES_PASSWORD
195197
pg_setup_hba_conf() {
196-
local authMethod
197-
if [ "$POSTGRES_PASSWORD" ]; then
198-
authMethod='md5'
199-
else
198+
local authMethod='md5'
199+
if [ -z "$POSTGRES_PASSWORD" ]; then
200200
authMethod='trust'
201201
fi
202202

@@ -232,7 +232,6 @@ _main() {
232232
set -- postgres "$@"
233233
fi
234234

235-
236235
if [ "$1" = 'postgres' ]; then
237236
docker_setup_env
238237
# setup data directories and permissions (when run as root)

11/alpine/docker-entrypoint.sh

+6-7
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ _is_sourced() {
3434

3535
# used to create initial posgres directories and if run as root, ensure ownership to the "postgres" user
3636
docker_create_db_directories() {
37-
local user="$(id -u)"
37+
local user; user="$(id -u)"
3838

3939
mkdir -p "$PGDATA"
4040
chmod 700 "$PGDATA"
@@ -46,7 +46,9 @@ docker_create_db_directories() {
4646
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
4747
if [ "$POSTGRES_INITDB_WALDIR" ]; then
4848
mkdir -p "$POSTGRES_INITDB_WALDIR"
49-
[ "$user" = '0' ] && find "$POSTGRES_INITDB_WALDIR" \! -user postgres - exec chown postgres '{}' +
49+
if [ "$user" = '0' ]; then
50+
find "$POSTGRES_INITDB_WALDIR" \! -user postgres -exec chown postgres '{}' +
51+
fi
5052
chmod 700 "$POSTGRES_INITDB_WALDIR"
5153
fi
5254

@@ -193,10 +195,8 @@ docker_setup_env() {
193195

194196
# append md5 or trust auth to pg_hba.conf based on existence of POSTGRES_PASSWORD
195197
pg_setup_hba_conf() {
196-
local authMethod
197-
if [ "$POSTGRES_PASSWORD" ]; then
198-
authMethod='md5'
199-
else
198+
local authMethod='md5'
199+
if [ -z "$POSTGRES_PASSWORD" ]; then
200200
authMethod='trust'
201201
fi
202202

@@ -232,7 +232,6 @@ _main() {
232232
set -- postgres "$@"
233233
fi
234234

235-
236235
if [ "$1" = 'postgres' ]; then
237236
docker_setup_env
238237
# setup data directories and permissions (when run as root)

11/docker-entrypoint.sh

+6-7
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ _is_sourced() {
3434

3535
# used to create initial posgres directories and if run as root, ensure ownership to the "postgres" user
3636
docker_create_db_directories() {
37-
local user="$(id -u)"
37+
local user; user="$(id -u)"
3838

3939
mkdir -p "$PGDATA"
4040
chmod 700 "$PGDATA"
@@ -46,7 +46,9 @@ docker_create_db_directories() {
4646
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
4747
if [ "$POSTGRES_INITDB_WALDIR" ]; then
4848
mkdir -p "$POSTGRES_INITDB_WALDIR"
49-
[ "$user" = '0' ] && find "$POSTGRES_INITDB_WALDIR" \! -user postgres - exec chown postgres '{}' +
49+
if [ "$user" = '0' ]; then
50+
find "$POSTGRES_INITDB_WALDIR" \! -user postgres -exec chown postgres '{}' +
51+
fi
5052
chmod 700 "$POSTGRES_INITDB_WALDIR"
5153
fi
5254

@@ -193,10 +195,8 @@ docker_setup_env() {
193195

194196
# append md5 or trust auth to pg_hba.conf based on existence of POSTGRES_PASSWORD
195197
pg_setup_hba_conf() {
196-
local authMethod
197-
if [ "$POSTGRES_PASSWORD" ]; then
198-
authMethod='md5'
199-
else
198+
local authMethod='md5'
199+
if [ -z "$POSTGRES_PASSWORD" ]; then
200200
authMethod='trust'
201201
fi
202202

@@ -232,7 +232,6 @@ _main() {
232232
set -- postgres "$@"
233233
fi
234234

235-
236235
if [ "$1" = 'postgres' ]; then
237236
docker_setup_env
238237
# setup data directories and permissions (when run as root)

12/alpine/docker-entrypoint.sh

+6-7
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ _is_sourced() {
3434

3535
# used to create initial posgres directories and if run as root, ensure ownership to the "postgres" user
3636
docker_create_db_directories() {
37-
local user="$(id -u)"
37+
local user; user="$(id -u)"
3838

3939
mkdir -p "$PGDATA"
4040
chmod 700 "$PGDATA"
@@ -46,7 +46,9 @@ docker_create_db_directories() {
4646
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
4747
if [ "$POSTGRES_INITDB_WALDIR" ]; then
4848
mkdir -p "$POSTGRES_INITDB_WALDIR"
49-
[ "$user" = '0' ] && find "$POSTGRES_INITDB_WALDIR" \! -user postgres - exec chown postgres '{}' +
49+
if [ "$user" = '0' ]; then
50+
find "$POSTGRES_INITDB_WALDIR" \! -user postgres -exec chown postgres '{}' +
51+
fi
5052
chmod 700 "$POSTGRES_INITDB_WALDIR"
5153
fi
5254

@@ -193,10 +195,8 @@ docker_setup_env() {
193195

194196
# append md5 or trust auth to pg_hba.conf based on existence of POSTGRES_PASSWORD
195197
pg_setup_hba_conf() {
196-
local authMethod
197-
if [ "$POSTGRES_PASSWORD" ]; then
198-
authMethod='md5'
199-
else
198+
local authMethod='md5'
199+
if [ -z "$POSTGRES_PASSWORD" ]; then
200200
authMethod='trust'
201201
fi
202202

@@ -232,7 +232,6 @@ _main() {
232232
set -- postgres "$@"
233233
fi
234234

235-
236235
if [ "$1" = 'postgres' ]; then
237236
docker_setup_env
238237
# setup data directories and permissions (when run as root)

12/docker-entrypoint.sh

+6-7
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ _is_sourced() {
3434

3535
# used to create initial posgres directories and if run as root, ensure ownership to the "postgres" user
3636
docker_create_db_directories() {
37-
local user="$(id -u)"
37+
local user; user="$(id -u)"
3838

3939
mkdir -p "$PGDATA"
4040
chmod 700 "$PGDATA"
@@ -46,7 +46,9 @@ docker_create_db_directories() {
4646
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
4747
if [ "$POSTGRES_INITDB_WALDIR" ]; then
4848
mkdir -p "$POSTGRES_INITDB_WALDIR"
49-
[ "$user" = '0' ] && find "$POSTGRES_INITDB_WALDIR" \! -user postgres - exec chown postgres '{}' +
49+
if [ "$user" = '0' ]; then
50+
find "$POSTGRES_INITDB_WALDIR" \! -user postgres -exec chown postgres '{}' +
51+
fi
5052
chmod 700 "$POSTGRES_INITDB_WALDIR"
5153
fi
5254

@@ -193,10 +195,8 @@ docker_setup_env() {
193195

194196
# append md5 or trust auth to pg_hba.conf based on existence of POSTGRES_PASSWORD
195197
pg_setup_hba_conf() {
196-
local authMethod
197-
if [ "$POSTGRES_PASSWORD" ]; then
198-
authMethod='md5'
199-
else
198+
local authMethod='md5'
199+
if [ -z "$POSTGRES_PASSWORD" ]; then
200200
authMethod='trust'
201201
fi
202202

@@ -232,7 +232,6 @@ _main() {
232232
set -- postgres "$@"
233233
fi
234234

235-
236235
if [ "$1" = 'postgres' ]; then
237236
docker_setup_env
238237
# setup data directories and permissions (when run as root)

9.4/alpine/docker-entrypoint.sh

+6-7
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ _is_sourced() {
3434

3535
# used to create initial posgres directories and if run as root, ensure ownership to the "postgres" user
3636
docker_create_db_directories() {
37-
local user="$(id -u)"
37+
local user; user="$(id -u)"
3838

3939
mkdir -p "$PGDATA"
4040
chmod 700 "$PGDATA"
@@ -46,7 +46,9 @@ docker_create_db_directories() {
4646
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
4747
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
4848
mkdir -p "$POSTGRES_INITDB_XLOGDIR"
49-
[ "$user" = '0' ] && find "$POSTGRES_INITDB_XLOGDIR" \! -user postgres - exec chown postgres '{}' +
49+
if [ "$user" = '0' ]; then
50+
find "$POSTGRES_INITDB_XLOGDIR" \! -user postgres -exec chown postgres '{}' +
51+
fi
5052
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
5153
fi
5254

@@ -193,10 +195,8 @@ docker_setup_env() {
193195

194196
# append md5 or trust auth to pg_hba.conf based on existence of POSTGRES_PASSWORD
195197
pg_setup_hba_conf() {
196-
local authMethod
197-
if [ "$POSTGRES_PASSWORD" ]; then
198-
authMethod='md5'
199-
else
198+
local authMethod='md5'
199+
if [ -z "$POSTGRES_PASSWORD" ]; then
200200
authMethod='trust'
201201
fi
202202

@@ -232,7 +232,6 @@ _main() {
232232
set -- postgres "$@"
233233
fi
234234

235-
236235
if [ "$1" = 'postgres' ]; then
237236
docker_setup_env
238237
# setup data directories and permissions (when run as root)

9.4/docker-entrypoint.sh

+6-7
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ _is_sourced() {
3434

3535
# used to create initial posgres directories and if run as root, ensure ownership to the "postgres" user
3636
docker_create_db_directories() {
37-
local user="$(id -u)"
37+
local user; user="$(id -u)"
3838

3939
mkdir -p "$PGDATA"
4040
chmod 700 "$PGDATA"
@@ -46,7 +46,9 @@ docker_create_db_directories() {
4646
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
4747
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
4848
mkdir -p "$POSTGRES_INITDB_XLOGDIR"
49-
[ "$user" = '0' ] && find "$POSTGRES_INITDB_XLOGDIR" \! -user postgres - exec chown postgres '{}' +
49+
if [ "$user" = '0' ]; then
50+
find "$POSTGRES_INITDB_XLOGDIR" \! -user postgres -exec chown postgres '{}' +
51+
fi
5052
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
5153
fi
5254

@@ -193,10 +195,8 @@ docker_setup_env() {
193195

194196
# append md5 or trust auth to pg_hba.conf based on existence of POSTGRES_PASSWORD
195197
pg_setup_hba_conf() {
196-
local authMethod
197-
if [ "$POSTGRES_PASSWORD" ]; then
198-
authMethod='md5'
199-
else
198+
local authMethod='md5'
199+
if [ -z "$POSTGRES_PASSWORD" ]; then
200200
authMethod='trust'
201201
fi
202202

@@ -232,7 +232,6 @@ _main() {
232232
set -- postgres "$@"
233233
fi
234234

235-
236235
if [ "$1" = 'postgres' ]; then
237236
docker_setup_env
238237
# setup data directories and permissions (when run as root)

9.5/alpine/docker-entrypoint.sh

+6-7
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ _is_sourced() {
3434

3535
# used to create initial posgres directories and if run as root, ensure ownership to the "postgres" user
3636
docker_create_db_directories() {
37-
local user="$(id -u)"
37+
local user; user="$(id -u)"
3838

3939
mkdir -p "$PGDATA"
4040
chmod 700 "$PGDATA"
@@ -46,7 +46,9 @@ docker_create_db_directories() {
4646
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
4747
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
4848
mkdir -p "$POSTGRES_INITDB_XLOGDIR"
49-
[ "$user" = '0' ] && find "$POSTGRES_INITDB_XLOGDIR" \! -user postgres - exec chown postgres '{}' +
49+
if [ "$user" = '0' ]; then
50+
find "$POSTGRES_INITDB_XLOGDIR" \! -user postgres -exec chown postgres '{}' +
51+
fi
5052
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
5153
fi
5254

@@ -193,10 +195,8 @@ docker_setup_env() {
193195

194196
# append md5 or trust auth to pg_hba.conf based on existence of POSTGRES_PASSWORD
195197
pg_setup_hba_conf() {
196-
local authMethod
197-
if [ "$POSTGRES_PASSWORD" ]; then
198-
authMethod='md5'
199-
else
198+
local authMethod='md5'
199+
if [ -z "$POSTGRES_PASSWORD" ]; then
200200
authMethod='trust'
201201
fi
202202

@@ -232,7 +232,6 @@ _main() {
232232
set -- postgres "$@"
233233
fi
234234

235-
236235
if [ "$1" = 'postgres' ]; then
237236
docker_setup_env
238237
# setup data directories and permissions (when run as root)

0 commit comments

Comments
 (0)