Skip to content

Commit a382cb1

Browse files
DEV: always change postgres permissions on existing data directory (#973)
If permissions of the initial data directory get changed, the install script is unable to reset the permissions to the expected user. The intent of the chown command is to ensure the permissions of the database and run directory are consistent and known. This allows it to do that on an existing data directory where this is more likely to occur. This uses a more consistent find command by moving chown command under exec Do not rely on a file glob which can error on too many files.
1 parent 072c526 commit a382cb1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

templates/postgres.template.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ run:
7777
if [ ! -e /shared/postgres_data ]; then
7878
install -d -m 0755 -o postgres -g postgres /shared/postgres_data
7979
sudo -E -u postgres /usr/lib/postgresql/15/bin/initdb -D /shared/postgres_data
80-
chown -R postgres:postgres /shared/postgres_data
81-
chown -R postgres:postgres /var/run/postgresql
8280
fi
81+
find /shared/postgres_data \! -user postgres -exec chown postgres '{}' +
82+
find /var/run/postgresql \! -user postgres -exec chown postgres '{}' +
8383
run_upgrade_postgres
8484
# Necessary to enable backups
8585
install -d -m 0755 -o postgres -g postgres /shared/postgres_backup

0 commit comments

Comments
 (0)