Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 1/trixie/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ docker_init_database_dir() {

# --pwfile refuses to handle a properly-empty file (hence the "\n"): https://github.com/docker-library/postgres/issues/1025
eval 'initdb --username="$IVORYSQL_USER" --pwfile=<(printf "%s\n" "$IVORYSQL_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"'
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" $PGDATA/postgresql.conf
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "$PGDATA/postgresql.conf"
if [ -e "$PGDATA/ivorysql.conf" ]; then
sed -ri "s!^#?(ivorysql.listen_addresses)\s*=\s*\S+.*!\1 = '*'!" $PGDATA/ivorysql.conf
sed -ri "s!^#?(ivorysql.listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "$PGDATA/ivorysql.conf"
fi
# unset/cleanup "nss_wrapper" bits
if [[ "${LD_PRELOAD:-}" == */libnss_wrapper.so ]]; then
Expand Down
4 changes: 2 additions & 2 deletions 3/bookworm/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ docker_init_database_dir() {

# --pwfile refuses to handle a properly-empty file (hence the "\n"): https://github.com/docker-library/postgres/issues/1025
eval 'initdb --username="$IVORYSQL_USER" --pwfile=<(printf "%s\n" "$IVORYSQL_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"'
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" $PGDATA/postgresql.conf
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "$PGDATA/postgresql.conf"
if [ -e "$PGDATA/ivorysql.conf" ]; then
sed -ri "s!^#?(ivorysql.listen_addresses)\s*=\s*\S+.*!\1 = '*'!" $PGDATA/ivorysql.conf
sed -ri "s!^#?(ivorysql.listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "$PGDATA/ivorysql.conf"
fi
# unset/cleanup "nss_wrapper" bits
if [[ "${LD_PRELOAD:-}" == */libnss_wrapper.so ]]; then
Expand Down
4 changes: 2 additions & 2 deletions 3/trixie/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ docker_init_database_dir() {

# --pwfile refuses to handle a properly-empty file (hence the "\n"): https://github.com/docker-library/postgres/issues/1025
eval 'initdb --username="$IVORYSQL_USER" --pwfile=<(printf "%s\n" "$IVORYSQL_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"'
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" $PGDATA/postgresql.conf
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "$PGDATA/postgresql.conf"
if [ -e "$PGDATA/ivorysql.conf" ]; then
sed -ri "s!^#?(ivorysql.listen_addresses)\s*=\s*\S+.*!\1 = '*'!" $PGDATA/ivorysql.conf
sed -ri "s!^#?(ivorysql.listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "$PGDATA/ivorysql.conf"
fi
# unset/cleanup "nss_wrapper" bits
if [[ "${LD_PRELOAD:-}" == */libnss_wrapper.so ]]; then
Expand Down
4 changes: 2 additions & 2 deletions 3/ubi8/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ docker_init_database_dir() {

# --pwfile refuses to handle a properly-empty file (hence the "\n"): https://github.com/docker-library/postgres/issues/1025
eval 'initdb --username="$IVORYSQL_USER" --pwfile=<(printf "%s\n" "$IVORYSQL_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"'
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" $PGDATA/postgresql.conf
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "$PGDATA/postgresql.conf"
if [ -e "$PGDATA/ivorysql.conf" ]; then
sed -ri "s!^#?(ivorysql.listen_addresses)\s*=\s*\S+.*!\1 = '*'!" $PGDATA/ivorysql.conf
sed -ri "s!^#?(ivorysql.listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "$PGDATA/ivorysql.conf"
fi
# unset/cleanup "nss_wrapper" bits
if [[ "${LD_PRELOAD:-}" == */libnss_wrapper.so ]]; then
Expand Down
4 changes: 2 additions & 2 deletions 4/bookworm/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ docker_init_database_dir() {

# --pwfile refuses to handle a properly-empty file (hence the "\n"): https://github.com/docker-library/postgres/issues/1025
eval 'initdb --username="$IVORYSQL_USER" --pwfile=<(printf "%s\n" "$IVORYSQL_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"'
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" $PGDATA/postgresql.conf
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "$PGDATA/postgresql.conf"
if [ -e "$PGDATA/ivorysql.conf" ]; then
sed -ri "s!^#?(ivorysql.listen_addresses)\s*=\s*\S+.*!\1 = '*'!" $PGDATA/ivorysql.conf
sed -ri "s!^#?(ivorysql.listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "$PGDATA/ivorysql.conf"
fi
# unset/cleanup "nss_wrapper" bits
if [[ "${LD_PRELOAD:-}" == */libnss_wrapper.so ]]; then
Expand Down
4 changes: 2 additions & 2 deletions 4/trixie/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ docker_init_database_dir() {

# --pwfile refuses to handle a properly-empty file (hence the "\n"): https://github.com/docker-library/postgres/issues/1025
eval 'initdb --username="$IVORYSQL_USER" --pwfile=<(printf "%s\n" "$IVORYSQL_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"'
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" $PGDATA/postgresql.conf
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "$PGDATA/postgresql.conf"
if [ -e "$PGDATA/ivorysql.conf" ]; then
sed -ri "s!^#?(ivorysql.listen_addresses)\s*=\s*\S+.*!\1 = '*'!" $PGDATA/ivorysql.conf
sed -ri "s!^#?(ivorysql.listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "$PGDATA/ivorysql.conf"
fi
# unset/cleanup "nss_wrapper" bits
if [[ "${LD_PRELOAD:-}" == */libnss_wrapper.so ]]; then
Expand Down
4 changes: 2 additions & 2 deletions 4/ubi8/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ docker_init_database_dir() {

# --pwfile refuses to handle a properly-empty file (hence the "\n"): https://github.com/docker-library/postgres/issues/1025
eval 'initdb --username="$IVORYSQL_USER" --pwfile=<(printf "%s\n" "$IVORYSQL_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"'
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" $PGDATA/postgresql.conf
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "$PGDATA/postgresql.conf"
if [ -e "$PGDATA/ivorysql.conf" ]; then
sed -ri "s!^#?(ivorysql.listen_addresses)\s*=\s*\S+.*!\1 = '*'!" $PGDATA/ivorysql.conf
sed -ri "s!^#?(ivorysql.listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "$PGDATA/ivorysql.conf"
fi
# unset/cleanup "nss_wrapper" bits
if [[ "${LD_PRELOAD:-}" == */libnss_wrapper.so ]]; then
Expand Down
4 changes: 2 additions & 2 deletions 5/bookworm/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ docker_init_database_dir() {

# --pwfile refuses to handle a properly-empty file (hence the "\n"): https://github.com/docker-library/postgres/issues/1025
eval 'initdb --username="$IVORYSQL_USER" --pwfile=<(printf "%s\n" "$IVORYSQL_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"'
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" $PGDATA/postgresql.conf
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "$PGDATA/postgresql.conf"
if [ -e "$PGDATA/ivorysql.conf" ]; then
sed -ri "s!^#?(ivorysql.listen_addresses)\s*=\s*\S+.*!\1 = '*'!" $PGDATA/ivorysql.conf
sed -ri "s!^#?(ivorysql.listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "$PGDATA/ivorysql.conf"
fi
# unset/cleanup "nss_wrapper" bits
if [[ "${LD_PRELOAD:-}" == */libnss_wrapper.so ]]; then
Expand Down
4 changes: 2 additions & 2 deletions 5/trixie/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ docker_init_database_dir() {

# --pwfile refuses to handle a properly-empty file (hence the "\n"): https://github.com/docker-library/postgres/issues/1025
eval 'initdb --username="$IVORYSQL_USER" --pwfile=<(printf "%s\n" "$IVORYSQL_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"'
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" $PGDATA/postgresql.conf
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "$PGDATA/postgresql.conf"
if [ -e "$PGDATA/ivorysql.conf" ]; then
sed -ri "s!^#?(ivorysql.listen_addresses)\s*=\s*\S+.*!\1 = '*'!" $PGDATA/ivorysql.conf
sed -ri "s!^#?(ivorysql.listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "$PGDATA/ivorysql.conf"
fi
# unset/cleanup "nss_wrapper" bits
if [[ "${LD_PRELOAD:-}" == */libnss_wrapper.so ]]; then
Expand Down
4 changes: 2 additions & 2 deletions 5/ubi8/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ docker_init_database_dir() {

# --pwfile refuses to handle a properly-empty file (hence the "\n"): https://github.com/docker-library/postgres/issues/1025
eval 'initdb --username="$IVORYSQL_USER" --pwfile=<(printf "%s\n" "$IVORYSQL_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"'
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" $PGDATA/postgresql.conf
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "$PGDATA/postgresql.conf"
if [ -e "$PGDATA/ivorysql.conf" ]; then
sed -ri "s!^#?(ivorysql.listen_addresses)\s*=\s*\S+.*!\1 = '*'!" $PGDATA/ivorysql.conf
sed -ri "s!^#?(ivorysql.listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "$PGDATA/ivorysql.conf"
fi
# unset/cleanup "nss_wrapper" bits
if [[ "${LD_PRELOAD:-}" == */libnss_wrapper.so ]]; then
Expand Down
4 changes: 2 additions & 2 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ docker_init_database_dir() {

# --pwfile refuses to handle a properly-empty file (hence the "\n"): https://github.com/docker-library/postgres/issues/1025
eval 'initdb --username="$IVORYSQL_USER" --pwfile=<(printf "%s\n" "$IVORYSQL_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"'
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" $PGDATA/postgresql.conf
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "$PGDATA/postgresql.conf"
if [ -e "$PGDATA/ivorysql.conf" ]; then
sed -ri "s!^#?(ivorysql.listen_addresses)\s*=\s*\S+.*!\1 = '*'!" $PGDATA/ivorysql.conf
sed -ri "s!^#?(ivorysql.listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "$PGDATA/ivorysql.conf"
fi
# unset/cleanup "nss_wrapper" bits
if [[ "${LD_PRELOAD:-}" == */libnss_wrapper.so ]]; then
Expand Down
32 changes: 32 additions & 0 deletions tests/entrypoint-pgdata.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
# Run from the repository root: bash tests/entrypoint-pgdata.sh
set -Eeuo pipefail
test_root=$(mktemp -d)
trap 'rm -rf "$test_root"' EXIT
for script in docker-entrypoint.sh [0-9]*/*/docker-entrypoint.sh; do
for directory in 'plain' 'data with spaces' 'data[1]'; do
for oracle_config in yes no; do
(
source "$script"
export PGDATA="$test_root/$directory" IVORYSQL_USER=test IVORYSQL_PASSWORD=test
POSTGRES_INITDB_ARGS=''
# Do not require a real initdb or an NSS entry for the test UID.
getent() { return 0; }
initdb() {
mkdir -p "$PGDATA"
printf "#listen_addresses = 'localhost'\n" > "$PGDATA/postgresql.conf"
rm -f "$PGDATA/ivorysql.conf"
if [[ $oracle_config == yes ]]; then
printf "#ivorysql.listen_addresses = 'localhost'\n" > "$PGDATA/ivorysql.conf"
fi
}
docker_init_database_dir
grep -Fx "listen_addresses = '*'" "$PGDATA/postgresql.conf" >/dev/null
if [[ $oracle_config == yes ]]; then
grep -Fx "ivorysql.listen_addresses = '*'" "$PGDATA/ivorysql.conf" >/dev/null
fi
)
done
done
done
echo 'All entrypoint PGDATA path checks passed'