File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,27 @@ if ! whoami > /dev/null 2>&1; then
2727 fi
2828fi
2929
30+ # Helper: chown a path only if it exists and isn't already owned correctly
31+ safe_chown () {
32+ local target=" $1 "
33+ local owner=" $2 :$3 " # UID:GID
34+
35+ # Skip if path doesn't exist
36+ [ -e " $target " ] || return 0
37+
38+ # Get current ownership
39+ local current_uid current_gid
40+ current_uid=$( stat -c ' %u' " $target " )
41+ current_gid=$( stat -c ' %g' " $target " )
42+
43+ # Skip if already owned correctly
44+ if [ " $current_uid " = " $1 " ] && [ " $current_gid " = " $2 " ]; then
45+ return 0
46+ fi
47+
48+ chown -R " $owner " " $target "
49+ }
50+
3051# usage: file_env VAR [DEFAULT] ie: file_env 'XYZ_DB_PASSWORD' 'example'
3152# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
3253# "$XYZ_DB_PASSWORD" from a file, for Docker's secrets feature)
197218TIMEOUT=$( cd /pgadmin4 && /venv/bin/python3 -c ' import config; print(config.SESSION_EXPIRATION_TIME * 60 * 60 * 24)' )
198219
199220if [ " $( id -u) " = " 0" ]; then
200- chown -R " $PUID :$PGID " /run/pgadmin /var/lib/pgadmin /pgadmin4/config_distro.py /certs
221+ for path in /run/pgadmin /var/lib/pgadmin " $CONFIG_DISTRO_FILE_PATH " /certs; do
222+ safe_chown " $path " " $PUID " " $PGID "
223+ done
201224fi
202225
203226# NOTE: currently pgadmin can run only with 1 worker due to sessions implementation
You can’t perform that action at this time.
0 commit comments