Skip to content

Commit 332c970

Browse files
committed
chore: Migrate to gosu
1 parent b9c2199 commit 332c970

File tree

9 files changed

+11
-11
lines changed

9 files changed

+11
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,4 @@ SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pi
120120
Then promote the replica. There are two options:
121121
- Create the `promote.signal` in the data directory `touch /var/lib/postgresql/data/promote.signal` on the replica.
122122
If you've changed your configuration, make sure `promote_trigger_file` declares that path.
123-
- Execute `su-exec postgres pg_ctl promote` in the container.
123+
- Execute `gosu postgres pg_ctl promote` in the container.

scripts/backup

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22
if [ "$(id -u)" == "1000" ]; then exec wal-g backup-push "$PGDATA" --config="$WALG_CONFIG_FILE"; fi
3-
exec su-exec postgres wal-g backup-push "$PGDATA" --config="$WALG_CONFIG_FILE"
3+
exec gosu postgres wal-g backup-push "$PGDATA" --config="$WALG_CONFIG_FILE"

scripts/entrypoint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if [ "$first" == "psql" ] || [ "$first" == "postgres" ] || [ "$first" == "pg_ctl
1414
if [ "$first" == "postgres" ] && [ ! -s "$PGDATA/PG_VERSION" ]; then /scripts/initdb; fi
1515

1616
[ "$(id -u)" == "1000" ] && exec "$@"
17-
exec su-exec postgres "$@"
17+
exec gosu postgres "$@"
1818
fi
1919

2020
exec "$@"

scripts/initdb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
set -Eeo pipefail
3-
if [ "$(id -u)" != "1000" ] ; then exec su-exec postgres "$BASH_SOURCE" "$@"; fi
3+
if [ "$(id -u)" != "1000" ] ; then exec gosu postgres "$BASH_SOURCE" "$@"; fi
44

55
source /usr/local/bin/docker-entrypoint.sh
66

scripts/pghba

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
set -Eeo pipefail
3-
if [ "$(id -u)" != "1000" ] ; then exec su-exec postgres "$BASH_SOURCE" "$@"; fi
3+
if [ "$(id -u)" != "1000" ] ; then exec gosu postgres "$BASH_SOURCE" "$@"; fi
44

55
TRUST=$1
66
if [ "$TRUST" == "" ] && [ "$POSTGRES_HOST_AUTH_METHOD" != "" ]; then TRUST=$POSTGRES_HOST_AUTH_METHOD; fi

scripts/recover

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
set -Eeo pipefail
3-
if [ "$(id -u)" != "1000" ] ; then exec su-exec postgres "$BASH_SOURCE" "$@"; fi
3+
if [ "$(id -u)" != "1000" ] ; then exec gosu postgres "$BASH_SOURCE" "$@"; fi
44
source /usr/local/bin/docker-entrypoint.sh
55

66
# When recovering, the database directory must be empty

scripts/standby

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
set -Eeo pipefail
3-
if [ "$(id -u)" != "1000" ] ; then exec su-exec postgres "$BASH_SOURCE" "$@"; fi
3+
if [ "$(id -u)" != "1000" ] ; then exec gosu postgres "$BASH_SOURCE" "$@"; fi
44

55
if [ -s "$PGDATA/PG_VERSION" ]; then exec postgres; fi
66
/scripts/recover -R "$@"

scripts/tuneconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
set -Eeo pipefail
3-
if [ "$(id -u)" != "1000" ] ; then exec su-exec postgres "$BASH_SOURCE" "$@"; fi
3+
if [ "$(id -u)" != "1000" ] ; then exec gosu postgres "$BASH_SOURCE" "$@"; fi
44

55
# Set the default socket directory to /var/run/postgresql or $PGHOST
66
sed -i "s?.*unix_socket_directories =.*?unix_socket_directories = '$PGHOST'?g" $PGDATA/postgresql.conf

scripts/upgrade

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ if [ -d "$PGDATANEW" ]; then
5959
fi
6060

6161
if [ "$(id -u)" != "1000" ] ; then
62-
PGDATA="$PGDATANEW" su-exec postgres:postgres $PGBINNEW/initdb
63-
PGDATA="$PGDATANEW" su-exec postgres:postgres /scripts/tuneconfig
64-
su-exec postgres:postgres pg_upgrade --link -j $(getconf _NPROCESSORS_ONLN)
62+
PGDATA="$PGDATANEW" gosu postgres:postgres $PGBINNEW/initdb
63+
PGDATA="$PGDATANEW" gosu postgres:postgres /scripts/tuneconfig
64+
gosu postgres:postgres pg_upgrade --link -j $(getconf _NPROCESSORS_ONLN)
6565
else
6666
PGDATA="$PGDATANEW" $PGBINNEW/initdb
6767
PGDATA="$PGDATANEW" /scripts/tuneconfig

0 commit comments

Comments
 (0)