From 8fada98158d5d19b538f1b10b3ed56d08c998bf0 Mon Sep 17 00:00:00 2001 From: Joe Ferguson Date: Tue, 12 Nov 2019 15:48:44 -0800 Subject: [PATCH] Fixes from tianon's review --- 10/alpine/docker-entrypoint.sh | 13 ++++++------- 10/docker-entrypoint.sh | 13 ++++++------- 11/alpine/docker-entrypoint.sh | 13 ++++++------- 11/docker-entrypoint.sh | 13 ++++++------- 12/alpine/docker-entrypoint.sh | 13 ++++++------- 12/docker-entrypoint.sh | 13 ++++++------- 9.4/alpine/docker-entrypoint.sh | 13 ++++++------- 9.4/docker-entrypoint.sh | 13 ++++++------- 9.5/alpine/docker-entrypoint.sh | 13 ++++++------- 9.5/docker-entrypoint.sh | 13 ++++++------- 9.6/alpine/docker-entrypoint.sh | 13 ++++++------- 9.6/docker-entrypoint.sh | 13 ++++++------- docker-entrypoint.sh | 13 ++++++------- 13 files changed, 78 insertions(+), 91 deletions(-) diff --git a/10/alpine/docker-entrypoint.sh b/10/alpine/docker-entrypoint.sh index 764c33275f..857389d553 100755 --- a/10/alpine/docker-entrypoint.sh +++ b/10/alpine/docker-entrypoint.sh @@ -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" @@ -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 @@ -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 @@ -232,7 +232,6 @@ _main() { set -- postgres "$@" fi - if [ "$1" = 'postgres' ]; then docker_setup_env # setup data directories and permissions (when run as root) diff --git a/10/docker-entrypoint.sh b/10/docker-entrypoint.sh index 75fcb02a07..02cb8e582a 100755 --- a/10/docker-entrypoint.sh +++ b/10/docker-entrypoint.sh @@ -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" @@ -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 @@ -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 @@ -232,7 +232,6 @@ _main() { set -- postgres "$@" fi - if [ "$1" = 'postgres' ]; then docker_setup_env # setup data directories and permissions (when run as root) diff --git a/11/alpine/docker-entrypoint.sh b/11/alpine/docker-entrypoint.sh index 764c33275f..857389d553 100755 --- a/11/alpine/docker-entrypoint.sh +++ b/11/alpine/docker-entrypoint.sh @@ -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" @@ -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 @@ -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 @@ -232,7 +232,6 @@ _main() { set -- postgres "$@" fi - if [ "$1" = 'postgres' ]; then docker_setup_env # setup data directories and permissions (when run as root) diff --git a/11/docker-entrypoint.sh b/11/docker-entrypoint.sh index 75fcb02a07..02cb8e582a 100755 --- a/11/docker-entrypoint.sh +++ b/11/docker-entrypoint.sh @@ -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" @@ -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 @@ -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 @@ -232,7 +232,6 @@ _main() { set -- postgres "$@" fi - if [ "$1" = 'postgres' ]; then docker_setup_env # setup data directories and permissions (when run as root) diff --git a/12/alpine/docker-entrypoint.sh b/12/alpine/docker-entrypoint.sh index 764c33275f..857389d553 100755 --- a/12/alpine/docker-entrypoint.sh +++ b/12/alpine/docker-entrypoint.sh @@ -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" @@ -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 @@ -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 @@ -232,7 +232,6 @@ _main() { set -- postgres "$@" fi - if [ "$1" = 'postgres' ]; then docker_setup_env # setup data directories and permissions (when run as root) diff --git a/12/docker-entrypoint.sh b/12/docker-entrypoint.sh index 75fcb02a07..02cb8e582a 100755 --- a/12/docker-entrypoint.sh +++ b/12/docker-entrypoint.sh @@ -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" @@ -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 @@ -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 @@ -232,7 +232,6 @@ _main() { set -- postgres "$@" fi - if [ "$1" = 'postgres' ]; then docker_setup_env # setup data directories and permissions (when run as root) diff --git a/9.4/alpine/docker-entrypoint.sh b/9.4/alpine/docker-entrypoint.sh index fdce2ecdbb..45bb6e1f5e 100755 --- a/9.4/alpine/docker-entrypoint.sh +++ b/9.4/alpine/docker-entrypoint.sh @@ -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" @@ -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 @@ -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 @@ -232,7 +232,6 @@ _main() { set -- postgres "$@" fi - if [ "$1" = 'postgres' ]; then docker_setup_env # setup data directories and permissions (when run as root) diff --git a/9.4/docker-entrypoint.sh b/9.4/docker-entrypoint.sh index e8051efe30..17b0a6878f 100755 --- a/9.4/docker-entrypoint.sh +++ b/9.4/docker-entrypoint.sh @@ -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" @@ -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 @@ -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 @@ -232,7 +232,6 @@ _main() { set -- postgres "$@" fi - if [ "$1" = 'postgres' ]; then docker_setup_env # setup data directories and permissions (when run as root) diff --git a/9.5/alpine/docker-entrypoint.sh b/9.5/alpine/docker-entrypoint.sh index fdce2ecdbb..45bb6e1f5e 100755 --- a/9.5/alpine/docker-entrypoint.sh +++ b/9.5/alpine/docker-entrypoint.sh @@ -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" @@ -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 @@ -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 @@ -232,7 +232,6 @@ _main() { set -- postgres "$@" fi - if [ "$1" = 'postgres' ]; then docker_setup_env # setup data directories and permissions (when run as root) diff --git a/9.5/docker-entrypoint.sh b/9.5/docker-entrypoint.sh index e8051efe30..17b0a6878f 100755 --- a/9.5/docker-entrypoint.sh +++ b/9.5/docker-entrypoint.sh @@ -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" @@ -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 @@ -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 @@ -232,7 +232,6 @@ _main() { set -- postgres "$@" fi - if [ "$1" = 'postgres' ]; then docker_setup_env # setup data directories and permissions (when run as root) diff --git a/9.6/alpine/docker-entrypoint.sh b/9.6/alpine/docker-entrypoint.sh index fdce2ecdbb..45bb6e1f5e 100755 --- a/9.6/alpine/docker-entrypoint.sh +++ b/9.6/alpine/docker-entrypoint.sh @@ -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" @@ -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 @@ -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 @@ -232,7 +232,6 @@ _main() { set -- postgres "$@" fi - if [ "$1" = 'postgres' ]; then docker_setup_env # setup data directories and permissions (when run as root) diff --git a/9.6/docker-entrypoint.sh b/9.6/docker-entrypoint.sh index e8051efe30..17b0a6878f 100755 --- a/9.6/docker-entrypoint.sh +++ b/9.6/docker-entrypoint.sh @@ -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" @@ -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 @@ -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 @@ -232,7 +232,6 @@ _main() { set -- postgres "$@" fi - if [ "$1" = 'postgres' ]; then docker_setup_env # setup data directories and permissions (when run as root) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 75fcb02a07..02cb8e582a 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -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" @@ -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 @@ -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 @@ -232,7 +232,6 @@ _main() { set -- postgres "$@" fi - if [ "$1" = 'postgres' ]; then docker_setup_env # setup data directories and permissions (when run as root)