Skip to content

Commit 0d0485c

Browse files
authored
Merge pull request #647 from infosiftr/help
Check for "help" to short circuit server starting (since they break when passed to pg_ctl)
2 parents ae986e1 + de2aa0b commit 0d0485c

13 files changed

+234
-13
lines changed

Diff for: 10/alpine/docker-entrypoint.sh

+18-1
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,30 @@ docker_temp_server_stop() {
229229
pg_ctl -D "$PGDATA" -m fast -w stop
230230
}
231231

232+
# check arguments for an option that would cause postgres to stop
233+
# return true if there is one
234+
_pg_want_help() {
235+
local arg
236+
for arg; do
237+
case "$arg" in
238+
# postgres --help | grep 'then exit'
239+
# leaving out -C on purpose since it always fails and is unhelpful:
240+
# postgres: could not access the server configuration file "/var/lib/postgresql/data/postgresql.conf": No such file or directory
241+
-'?'|--help|--describe-config|-V|--version)
242+
return 0
243+
;;
244+
esac
245+
done
246+
return 1
247+
}
248+
232249
_main() {
233250
# if first arg looks like a flag, assume we want to run postgres server
234251
if [ "${1:0:1}" = '-' ]; then
235252
set -- postgres "$@"
236253
fi
237254

238-
if [ "$1" = 'postgres' ]; then
255+
if [ "$1" = 'postgres' ] && ! _pg_want_help "$@"; then
239256
docker_setup_env
240257
# setup data directories and permissions (when run as root)
241258
docker_create_db_directories

Diff for: 10/docker-entrypoint.sh

+18-1
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,30 @@ docker_temp_server_stop() {
229229
pg_ctl -D "$PGDATA" -m fast -w stop
230230
}
231231

232+
# check arguments for an option that would cause postgres to stop
233+
# return true if there is one
234+
_pg_want_help() {
235+
local arg
236+
for arg; do
237+
case "$arg" in
238+
# postgres --help | grep 'then exit'
239+
# leaving out -C on purpose since it always fails and is unhelpful:
240+
# postgres: could not access the server configuration file "/var/lib/postgresql/data/postgresql.conf": No such file or directory
241+
-'?'|--help|--describe-config|-V|--version)
242+
return 0
243+
;;
244+
esac
245+
done
246+
return 1
247+
}
248+
232249
_main() {
233250
# if first arg looks like a flag, assume we want to run postgres server
234251
if [ "${1:0:1}" = '-' ]; then
235252
set -- postgres "$@"
236253
fi
237254

238-
if [ "$1" = 'postgres' ]; then
255+
if [ "$1" = 'postgres' ] && ! _pg_want_help "$@"; then
239256
docker_setup_env
240257
# setup data directories and permissions (when run as root)
241258
docker_create_db_directories

Diff for: 11/alpine/docker-entrypoint.sh

+18-1
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,30 @@ docker_temp_server_stop() {
229229
pg_ctl -D "$PGDATA" -m fast -w stop
230230
}
231231

232+
# check arguments for an option that would cause postgres to stop
233+
# return true if there is one
234+
_pg_want_help() {
235+
local arg
236+
for arg; do
237+
case "$arg" in
238+
# postgres --help | grep 'then exit'
239+
# leaving out -C on purpose since it always fails and is unhelpful:
240+
# postgres: could not access the server configuration file "/var/lib/postgresql/data/postgresql.conf": No such file or directory
241+
-'?'|--help|--describe-config|-V|--version)
242+
return 0
243+
;;
244+
esac
245+
done
246+
return 1
247+
}
248+
232249
_main() {
233250
# if first arg looks like a flag, assume we want to run postgres server
234251
if [ "${1:0:1}" = '-' ]; then
235252
set -- postgres "$@"
236253
fi
237254

238-
if [ "$1" = 'postgres' ]; then
255+
if [ "$1" = 'postgres' ] && ! _pg_want_help "$@"; then
239256
docker_setup_env
240257
# setup data directories and permissions (when run as root)
241258
docker_create_db_directories

Diff for: 11/docker-entrypoint.sh

+18-1
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,30 @@ docker_temp_server_stop() {
229229
pg_ctl -D "$PGDATA" -m fast -w stop
230230
}
231231

232+
# check arguments for an option that would cause postgres to stop
233+
# return true if there is one
234+
_pg_want_help() {
235+
local arg
236+
for arg; do
237+
case "$arg" in
238+
# postgres --help | grep 'then exit'
239+
# leaving out -C on purpose since it always fails and is unhelpful:
240+
# postgres: could not access the server configuration file "/var/lib/postgresql/data/postgresql.conf": No such file or directory
241+
-'?'|--help|--describe-config|-V|--version)
242+
return 0
243+
;;
244+
esac
245+
done
246+
return 1
247+
}
248+
232249
_main() {
233250
# if first arg looks like a flag, assume we want to run postgres server
234251
if [ "${1:0:1}" = '-' ]; then
235252
set -- postgres "$@"
236253
fi
237254

238-
if [ "$1" = 'postgres' ]; then
255+
if [ "$1" = 'postgres' ] && ! _pg_want_help "$@"; then
239256
docker_setup_env
240257
# setup data directories and permissions (when run as root)
241258
docker_create_db_directories

Diff for: 12/alpine/docker-entrypoint.sh

+18-1
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,30 @@ docker_temp_server_stop() {
229229
pg_ctl -D "$PGDATA" -m fast -w stop
230230
}
231231

232+
# check arguments for an option that would cause postgres to stop
233+
# return true if there is one
234+
_pg_want_help() {
235+
local arg
236+
for arg; do
237+
case "$arg" in
238+
# postgres --help | grep 'then exit'
239+
# leaving out -C on purpose since it always fails and is unhelpful:
240+
# postgres: could not access the server configuration file "/var/lib/postgresql/data/postgresql.conf": No such file or directory
241+
-'?'|--help|--describe-config|-V|--version)
242+
return 0
243+
;;
244+
esac
245+
done
246+
return 1
247+
}
248+
232249
_main() {
233250
# if first arg looks like a flag, assume we want to run postgres server
234251
if [ "${1:0:1}" = '-' ]; then
235252
set -- postgres "$@"
236253
fi
237254

238-
if [ "$1" = 'postgres' ]; then
255+
if [ "$1" = 'postgres' ] && ! _pg_want_help "$@"; then
239256
docker_setup_env
240257
# setup data directories and permissions (when run as root)
241258
docker_create_db_directories

Diff for: 12/docker-entrypoint.sh

+18-1
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,30 @@ docker_temp_server_stop() {
229229
pg_ctl -D "$PGDATA" -m fast -w stop
230230
}
231231

232+
# check arguments for an option that would cause postgres to stop
233+
# return true if there is one
234+
_pg_want_help() {
235+
local arg
236+
for arg; do
237+
case "$arg" in
238+
# postgres --help | grep 'then exit'
239+
# leaving out -C on purpose since it always fails and is unhelpful:
240+
# postgres: could not access the server configuration file "/var/lib/postgresql/data/postgresql.conf": No such file or directory
241+
-'?'|--help|--describe-config|-V|--version)
242+
return 0
243+
;;
244+
esac
245+
done
246+
return 1
247+
}
248+
232249
_main() {
233250
# if first arg looks like a flag, assume we want to run postgres server
234251
if [ "${1:0:1}" = '-' ]; then
235252
set -- postgres "$@"
236253
fi
237254

238-
if [ "$1" = 'postgres' ]; then
255+
if [ "$1" = 'postgres' ] && ! _pg_want_help "$@"; then
239256
docker_setup_env
240257
# setup data directories and permissions (when run as root)
241258
docker_create_db_directories

Diff for: 9.4/alpine/docker-entrypoint.sh

+18-1
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,30 @@ docker_temp_server_stop() {
229229
pg_ctl -D "$PGDATA" -m fast -w stop
230230
}
231231

232+
# check arguments for an option that would cause postgres to stop
233+
# return true if there is one
234+
_pg_want_help() {
235+
local arg
236+
for arg; do
237+
case "$arg" in
238+
# postgres --help | grep 'then exit'
239+
# leaving out -C on purpose since it always fails and is unhelpful:
240+
# postgres: could not access the server configuration file "/var/lib/postgresql/data/postgresql.conf": No such file or directory
241+
-'?'|--help|--describe-config|-V|--version)
242+
return 0
243+
;;
244+
esac
245+
done
246+
return 1
247+
}
248+
232249
_main() {
233250
# if first arg looks like a flag, assume we want to run postgres server
234251
if [ "${1:0:1}" = '-' ]; then
235252
set -- postgres "$@"
236253
fi
237254

238-
if [ "$1" = 'postgres' ]; then
255+
if [ "$1" = 'postgres' ] && ! _pg_want_help "$@"; then
239256
docker_setup_env
240257
# setup data directories and permissions (when run as root)
241258
docker_create_db_directories

Diff for: 9.4/docker-entrypoint.sh

+18-1
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,30 @@ docker_temp_server_stop() {
229229
pg_ctl -D "$PGDATA" -m fast -w stop
230230
}
231231

232+
# check arguments for an option that would cause postgres to stop
233+
# return true if there is one
234+
_pg_want_help() {
235+
local arg
236+
for arg; do
237+
case "$arg" in
238+
# postgres --help | grep 'then exit'
239+
# leaving out -C on purpose since it always fails and is unhelpful:
240+
# postgres: could not access the server configuration file "/var/lib/postgresql/data/postgresql.conf": No such file or directory
241+
-'?'|--help|--describe-config|-V|--version)
242+
return 0
243+
;;
244+
esac
245+
done
246+
return 1
247+
}
248+
232249
_main() {
233250
# if first arg looks like a flag, assume we want to run postgres server
234251
if [ "${1:0:1}" = '-' ]; then
235252
set -- postgres "$@"
236253
fi
237254

238-
if [ "$1" = 'postgres' ]; then
255+
if [ "$1" = 'postgres' ] && ! _pg_want_help "$@"; then
239256
docker_setup_env
240257
# setup data directories and permissions (when run as root)
241258
docker_create_db_directories

Diff for: 9.5/alpine/docker-entrypoint.sh

+18-1
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,30 @@ docker_temp_server_stop() {
229229
pg_ctl -D "$PGDATA" -m fast -w stop
230230
}
231231

232+
# check arguments for an option that would cause postgres to stop
233+
# return true if there is one
234+
_pg_want_help() {
235+
local arg
236+
for arg; do
237+
case "$arg" in
238+
# postgres --help | grep 'then exit'
239+
# leaving out -C on purpose since it always fails and is unhelpful:
240+
# postgres: could not access the server configuration file "/var/lib/postgresql/data/postgresql.conf": No such file or directory
241+
-'?'|--help|--describe-config|-V|--version)
242+
return 0
243+
;;
244+
esac
245+
done
246+
return 1
247+
}
248+
232249
_main() {
233250
# if first arg looks like a flag, assume we want to run postgres server
234251
if [ "${1:0:1}" = '-' ]; then
235252
set -- postgres "$@"
236253
fi
237254

238-
if [ "$1" = 'postgres' ]; then
255+
if [ "$1" = 'postgres' ] && ! _pg_want_help "$@"; then
239256
docker_setup_env
240257
# setup data directories and permissions (when run as root)
241258
docker_create_db_directories

Diff for: 9.5/docker-entrypoint.sh

+18-1
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,30 @@ docker_temp_server_stop() {
229229
pg_ctl -D "$PGDATA" -m fast -w stop
230230
}
231231

232+
# check arguments for an option that would cause postgres to stop
233+
# return true if there is one
234+
_pg_want_help() {
235+
local arg
236+
for arg; do
237+
case "$arg" in
238+
# postgres --help | grep 'then exit'
239+
# leaving out -C on purpose since it always fails and is unhelpful:
240+
# postgres: could not access the server configuration file "/var/lib/postgresql/data/postgresql.conf": No such file or directory
241+
-'?'|--help|--describe-config|-V|--version)
242+
return 0
243+
;;
244+
esac
245+
done
246+
return 1
247+
}
248+
232249
_main() {
233250
# if first arg looks like a flag, assume we want to run postgres server
234251
if [ "${1:0:1}" = '-' ]; then
235252
set -- postgres "$@"
236253
fi
237254

238-
if [ "$1" = 'postgres' ]; then
255+
if [ "$1" = 'postgres' ] && ! _pg_want_help "$@"; then
239256
docker_setup_env
240257
# setup data directories and permissions (when run as root)
241258
docker_create_db_directories

Diff for: 9.6/alpine/docker-entrypoint.sh

+18-1
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,30 @@ docker_temp_server_stop() {
229229
pg_ctl -D "$PGDATA" -m fast -w stop
230230
}
231231

232+
# check arguments for an option that would cause postgres to stop
233+
# return true if there is one
234+
_pg_want_help() {
235+
local arg
236+
for arg; do
237+
case "$arg" in
238+
# postgres --help | grep 'then exit'
239+
# leaving out -C on purpose since it always fails and is unhelpful:
240+
# postgres: could not access the server configuration file "/var/lib/postgresql/data/postgresql.conf": No such file or directory
241+
-'?'|--help|--describe-config|-V|--version)
242+
return 0
243+
;;
244+
esac
245+
done
246+
return 1
247+
}
248+
232249
_main() {
233250
# if first arg looks like a flag, assume we want to run postgres server
234251
if [ "${1:0:1}" = '-' ]; then
235252
set -- postgres "$@"
236253
fi
237254

238-
if [ "$1" = 'postgres' ]; then
255+
if [ "$1" = 'postgres' ] && ! _pg_want_help "$@"; then
239256
docker_setup_env
240257
# setup data directories and permissions (when run as root)
241258
docker_create_db_directories

Diff for: 9.6/docker-entrypoint.sh

+18-1
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,30 @@ docker_temp_server_stop() {
229229
pg_ctl -D "$PGDATA" -m fast -w stop
230230
}
231231

232+
# check arguments for an option that would cause postgres to stop
233+
# return true if there is one
234+
_pg_want_help() {
235+
local arg
236+
for arg; do
237+
case "$arg" in
238+
# postgres --help | grep 'then exit'
239+
# leaving out -C on purpose since it always fails and is unhelpful:
240+
# postgres: could not access the server configuration file "/var/lib/postgresql/data/postgresql.conf": No such file or directory
241+
-'?'|--help|--describe-config|-V|--version)
242+
return 0
243+
;;
244+
esac
245+
done
246+
return 1
247+
}
248+
232249
_main() {
233250
# if first arg looks like a flag, assume we want to run postgres server
234251
if [ "${1:0:1}" = '-' ]; then
235252
set -- postgres "$@"
236253
fi
237254

238-
if [ "$1" = 'postgres' ]; then
255+
if [ "$1" = 'postgres' ] && ! _pg_want_help "$@"; then
239256
docker_setup_env
240257
# setup data directories and permissions (when run as root)
241258
docker_create_db_directories

0 commit comments

Comments
 (0)