From 9f2d9ed82b50481f9087361b9d63164d6bd5f318 Mon Sep 17 00:00:00 2001 From: Roland Date: Mon, 6 Jul 2026 15:39:03 -0600 Subject: [PATCH] repair.sh: key the Portable postgres ownership restore off the active bind. Portable is defined by the live boot medium (wrolpi-bootstrap MODE), and its visible effect at repair time is the bind of the cluster over /var/lib/postgresql. Restore postgres ownership only when that bind is active, and restore the bind targets themselves; on installed systems a config/postgresql directory is inert (dead weight from the old layout, or a user's backup on the drive) and must not be touched. Co-Authored-By: Claude Fable 5 --- repair.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/repair.sh b/repair.sh index 367b30e6..057cd3d5 100755 --- a/repair.sh +++ b/repair.sh @@ -165,11 +165,12 @@ fi chown wrolpi:wrolpi /media/wrolpi 2>/dev/null || echo "Ignoring failure to change media directory permissions." # Ensure the config directory is owned by wrolpi so the API can write config files. [ -d /media/wrolpi/config ] && chown -R wrolpi:wrolpi /media/wrolpi/config 2>/dev/null || : -# On bootstrapped systems the Postgres cluster lives under config/postgresql (bind-mounted to -# /var/lib/postgresql and /etc/postgresql). It must stay owned by postgres, or new backends -# die with: FATAL: could not open file "global/pg_filenode.map": Permission denied. -if [ -d /media/wrolpi/config/postgresql ] && id postgres >/dev/null 2>&1; then - chown -R postgres:postgres /media/wrolpi/config/postgresql 2>/dev/null || : +# On Portable (live-boot) systems the Postgres cluster lives under config/postgresql, +# bind-mounted over /var/lib/postgresql — so the config chown above just swept it. Restore +# ownership only when that bind is active; on installed systems Postgres lives on the root +# filesystem and any config/postgresql directory is inert (dead weight or a user's backup). +if mountpoint -q /var/lib/postgresql 2>/dev/null && id postgres >/dev/null 2>&1; then + chown -R postgres:postgres /var/lib/postgresql /etc/postgresql 2>/dev/null || : fi # Remove immutable flag from blob files before chown (may not exist or may not be set).