Skip to content

Commit

Permalink
Fixes from tianon's review
Browse files Browse the repository at this point in the history
  • Loading branch information
yosifkit committed Nov 13, 2019
1 parent 7c84645 commit 8fada98
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 91 deletions.
13 changes: 6 additions & 7 deletions 10/alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ _is_sourced() {

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

mkdir -p "$PGDATA"
chmod 700 "$PGDATA"
Expand All @@ -46,7 +46,9 @@ docker_create_db_directories() {
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
if [ "$POSTGRES_INITDB_WALDIR" ]; then
mkdir -p "$POSTGRES_INITDB_WALDIR"
[ "$user" = '0' ] && find "$POSTGRES_INITDB_WALDIR" \! -user postgres - exec chown postgres '{}' +
if [ "$user" = '0' ]; then
find "$POSTGRES_INITDB_WALDIR" \! -user postgres -exec chown postgres '{}' +
fi
chmod 700 "$POSTGRES_INITDB_WALDIR"
fi

Expand Down Expand Up @@ -193,10 +195,8 @@ docker_setup_env() {

# append md5 or trust auth to pg_hba.conf based on existence of POSTGRES_PASSWORD
pg_setup_hba_conf() {
local authMethod
if [ "$POSTGRES_PASSWORD" ]; then
authMethod='md5'
else
local authMethod='md5'
if [ -z "$POSTGRES_PASSWORD" ]; then
authMethod='trust'
fi

Expand Down Expand Up @@ -232,7 +232,6 @@ _main() {
set -- postgres "$@"
fi


if [ "$1" = 'postgres' ]; then
docker_setup_env
# setup data directories and permissions (when run as root)
Expand Down
13 changes: 6 additions & 7 deletions 10/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ _is_sourced() {

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

mkdir -p "$PGDATA"
chmod 700 "$PGDATA"
Expand All @@ -46,7 +46,9 @@ docker_create_db_directories() {
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
if [ "$POSTGRES_INITDB_WALDIR" ]; then
mkdir -p "$POSTGRES_INITDB_WALDIR"
[ "$user" = '0' ] && find "$POSTGRES_INITDB_WALDIR" \! -user postgres - exec chown postgres '{}' +
if [ "$user" = '0' ]; then
find "$POSTGRES_INITDB_WALDIR" \! -user postgres -exec chown postgres '{}' +
fi
chmod 700 "$POSTGRES_INITDB_WALDIR"
fi

Expand Down Expand Up @@ -193,10 +195,8 @@ docker_setup_env() {

# append md5 or trust auth to pg_hba.conf based on existence of POSTGRES_PASSWORD
pg_setup_hba_conf() {
local authMethod
if [ "$POSTGRES_PASSWORD" ]; then
authMethod='md5'
else
local authMethod='md5'
if [ -z "$POSTGRES_PASSWORD" ]; then
authMethod='trust'
fi

Expand Down Expand Up @@ -232,7 +232,6 @@ _main() {
set -- postgres "$@"
fi


if [ "$1" = 'postgres' ]; then
docker_setup_env
# setup data directories and permissions (when run as root)
Expand Down
13 changes: 6 additions & 7 deletions 11/alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ _is_sourced() {

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

mkdir -p "$PGDATA"
chmod 700 "$PGDATA"
Expand All @@ -46,7 +46,9 @@ docker_create_db_directories() {
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
if [ "$POSTGRES_INITDB_WALDIR" ]; then
mkdir -p "$POSTGRES_INITDB_WALDIR"
[ "$user" = '0' ] && find "$POSTGRES_INITDB_WALDIR" \! -user postgres - exec chown postgres '{}' +
if [ "$user" = '0' ]; then
find "$POSTGRES_INITDB_WALDIR" \! -user postgres -exec chown postgres '{}' +
fi
chmod 700 "$POSTGRES_INITDB_WALDIR"
fi

Expand Down Expand Up @@ -193,10 +195,8 @@ docker_setup_env() {

# append md5 or trust auth to pg_hba.conf based on existence of POSTGRES_PASSWORD
pg_setup_hba_conf() {
local authMethod
if [ "$POSTGRES_PASSWORD" ]; then
authMethod='md5'
else
local authMethod='md5'
if [ -z "$POSTGRES_PASSWORD" ]; then
authMethod='trust'
fi

Expand Down Expand Up @@ -232,7 +232,6 @@ _main() {
set -- postgres "$@"
fi


if [ "$1" = 'postgres' ]; then
docker_setup_env
# setup data directories and permissions (when run as root)
Expand Down
13 changes: 6 additions & 7 deletions 11/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ _is_sourced() {

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

mkdir -p "$PGDATA"
chmod 700 "$PGDATA"
Expand All @@ -46,7 +46,9 @@ docker_create_db_directories() {
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
if [ "$POSTGRES_INITDB_WALDIR" ]; then
mkdir -p "$POSTGRES_INITDB_WALDIR"
[ "$user" = '0' ] && find "$POSTGRES_INITDB_WALDIR" \! -user postgres - exec chown postgres '{}' +
if [ "$user" = '0' ]; then
find "$POSTGRES_INITDB_WALDIR" \! -user postgres -exec chown postgres '{}' +
fi
chmod 700 "$POSTGRES_INITDB_WALDIR"
fi

Expand Down Expand Up @@ -193,10 +195,8 @@ docker_setup_env() {

# append md5 or trust auth to pg_hba.conf based on existence of POSTGRES_PASSWORD
pg_setup_hba_conf() {
local authMethod
if [ "$POSTGRES_PASSWORD" ]; then
authMethod='md5'
else
local authMethod='md5'
if [ -z "$POSTGRES_PASSWORD" ]; then
authMethod='trust'
fi

Expand Down Expand Up @@ -232,7 +232,6 @@ _main() {
set -- postgres "$@"
fi


if [ "$1" = 'postgres' ]; then
docker_setup_env
# setup data directories and permissions (when run as root)
Expand Down
13 changes: 6 additions & 7 deletions 12/alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ _is_sourced() {

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

mkdir -p "$PGDATA"
chmod 700 "$PGDATA"
Expand All @@ -46,7 +46,9 @@ docker_create_db_directories() {
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
if [ "$POSTGRES_INITDB_WALDIR" ]; then
mkdir -p "$POSTGRES_INITDB_WALDIR"
[ "$user" = '0' ] && find "$POSTGRES_INITDB_WALDIR" \! -user postgres - exec chown postgres '{}' +
if [ "$user" = '0' ]; then
find "$POSTGRES_INITDB_WALDIR" \! -user postgres -exec chown postgres '{}' +
fi
chmod 700 "$POSTGRES_INITDB_WALDIR"
fi

Expand Down Expand Up @@ -193,10 +195,8 @@ docker_setup_env() {

# append md5 or trust auth to pg_hba.conf based on existence of POSTGRES_PASSWORD
pg_setup_hba_conf() {
local authMethod
if [ "$POSTGRES_PASSWORD" ]; then
authMethod='md5'
else
local authMethod='md5'
if [ -z "$POSTGRES_PASSWORD" ]; then
authMethod='trust'
fi

Expand Down Expand Up @@ -232,7 +232,6 @@ _main() {
set -- postgres "$@"
fi


if [ "$1" = 'postgres' ]; then
docker_setup_env
# setup data directories and permissions (when run as root)
Expand Down
13 changes: 6 additions & 7 deletions 12/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ _is_sourced() {

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

mkdir -p "$PGDATA"
chmod 700 "$PGDATA"
Expand All @@ -46,7 +46,9 @@ docker_create_db_directories() {
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
if [ "$POSTGRES_INITDB_WALDIR" ]; then
mkdir -p "$POSTGRES_INITDB_WALDIR"
[ "$user" = '0' ] && find "$POSTGRES_INITDB_WALDIR" \! -user postgres - exec chown postgres '{}' +
if [ "$user" = '0' ]; then
find "$POSTGRES_INITDB_WALDIR" \! -user postgres -exec chown postgres '{}' +
fi
chmod 700 "$POSTGRES_INITDB_WALDIR"
fi

Expand Down Expand Up @@ -193,10 +195,8 @@ docker_setup_env() {

# append md5 or trust auth to pg_hba.conf based on existence of POSTGRES_PASSWORD
pg_setup_hba_conf() {
local authMethod
if [ "$POSTGRES_PASSWORD" ]; then
authMethod='md5'
else
local authMethod='md5'
if [ -z "$POSTGRES_PASSWORD" ]; then
authMethod='trust'
fi

Expand Down Expand Up @@ -232,7 +232,6 @@ _main() {
set -- postgres "$@"
fi


if [ "$1" = 'postgres' ]; then
docker_setup_env
# setup data directories and permissions (when run as root)
Expand Down
13 changes: 6 additions & 7 deletions 9.4/alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ _is_sourced() {

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

mkdir -p "$PGDATA"
chmod 700 "$PGDATA"
Expand All @@ -46,7 +46,9 @@ docker_create_db_directories() {
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
mkdir -p "$POSTGRES_INITDB_XLOGDIR"
[ "$user" = '0' ] && find "$POSTGRES_INITDB_XLOGDIR" \! -user postgres - exec chown postgres '{}' +
if [ "$user" = '0' ]; then
find "$POSTGRES_INITDB_XLOGDIR" \! -user postgres -exec chown postgres '{}' +
fi
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
fi

Expand Down Expand Up @@ -193,10 +195,8 @@ docker_setup_env() {

# append md5 or trust auth to pg_hba.conf based on existence of POSTGRES_PASSWORD
pg_setup_hba_conf() {
local authMethod
if [ "$POSTGRES_PASSWORD" ]; then
authMethod='md5'
else
local authMethod='md5'
if [ -z "$POSTGRES_PASSWORD" ]; then
authMethod='trust'
fi

Expand Down Expand Up @@ -232,7 +232,6 @@ _main() {
set -- postgres "$@"
fi


if [ "$1" = 'postgres' ]; then
docker_setup_env
# setup data directories and permissions (when run as root)
Expand Down
13 changes: 6 additions & 7 deletions 9.4/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ _is_sourced() {

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

mkdir -p "$PGDATA"
chmod 700 "$PGDATA"
Expand All @@ -46,7 +46,9 @@ docker_create_db_directories() {
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
mkdir -p "$POSTGRES_INITDB_XLOGDIR"
[ "$user" = '0' ] && find "$POSTGRES_INITDB_XLOGDIR" \! -user postgres - exec chown postgres '{}' +
if [ "$user" = '0' ]; then
find "$POSTGRES_INITDB_XLOGDIR" \! -user postgres -exec chown postgres '{}' +
fi
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
fi

Expand Down Expand Up @@ -193,10 +195,8 @@ docker_setup_env() {

# append md5 or trust auth to pg_hba.conf based on existence of POSTGRES_PASSWORD
pg_setup_hba_conf() {
local authMethod
if [ "$POSTGRES_PASSWORD" ]; then
authMethod='md5'
else
local authMethod='md5'
if [ -z "$POSTGRES_PASSWORD" ]; then
authMethod='trust'
fi

Expand Down Expand Up @@ -232,7 +232,6 @@ _main() {
set -- postgres "$@"
fi


if [ "$1" = 'postgres' ]; then
docker_setup_env
# setup data directories and permissions (when run as root)
Expand Down
13 changes: 6 additions & 7 deletions 9.5/alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ _is_sourced() {

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

mkdir -p "$PGDATA"
chmod 700 "$PGDATA"
Expand All @@ -46,7 +46,9 @@ docker_create_db_directories() {
# Create the transaction log directory before initdb is run so the directory is owned by the correct user
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
mkdir -p "$POSTGRES_INITDB_XLOGDIR"
[ "$user" = '0' ] && find "$POSTGRES_INITDB_XLOGDIR" \! -user postgres - exec chown postgres '{}' +
if [ "$user" = '0' ]; then
find "$POSTGRES_INITDB_XLOGDIR" \! -user postgres -exec chown postgres '{}' +
fi
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
fi

Expand Down Expand Up @@ -193,10 +195,8 @@ docker_setup_env() {

# append md5 or trust auth to pg_hba.conf based on existence of POSTGRES_PASSWORD
pg_setup_hba_conf() {
local authMethod
if [ "$POSTGRES_PASSWORD" ]; then
authMethod='md5'
else
local authMethod='md5'
if [ -z "$POSTGRES_PASSWORD" ]; then
authMethod='trust'
fi

Expand Down Expand Up @@ -232,7 +232,6 @@ _main() {
set -- postgres "$@"
fi


if [ "$1" = 'postgres' ]; then
docker_setup_env
# setup data directories and permissions (when run as root)
Expand Down
Loading

0 comments on commit 8fada98

Please sign in to comment.