mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 10:51:36 -04:00
repair.sh: heal Postgres cluster ownership non-destructively.
The only self-service fix for a permission-broken cluster was reset_api_db.sh, which drops the database. Repair now restores postgres ownership of /var/lib/postgresql and /etc/postgresql and restarts Postgres before configuring the database, same as the reset script but keeping the data. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
3180a29e82
commit
fdf65e218e
1 changed files with 11 additions and 0 deletions
11
repair.sh
11
repair.sh
|
|
@ -143,6 +143,17 @@ chmod 0440 /etc/sudoers.d/90-wrolpi
|
|||
# Verify this new file is valid.
|
||||
visudo -c -f /etc/sudoers.d/90-wrolpi
|
||||
|
||||
# Heal Postgres cluster ownership before configuring the database. A stray
|
||||
# recursive chown can leave cluster files unreadable by the server: the
|
||||
# postmaster stays up but new backends die with FATAL: could not open file
|
||||
# "global/pg_filenode.map": Permission denied. Same healing as
|
||||
# reset_api_db.sh, but without dropping the database.
|
||||
if id postgres >/dev/null 2>&1; then
|
||||
[ -d /var/lib/postgresql ] && chown -R postgres:postgres /var/lib/postgresql 2>/dev/null || :
|
||||
[ -d /etc/postgresql ] && chown -R postgres:postgres /etc/postgresql 2>/dev/null || :
|
||||
systemctl restart postgresql 2>/dev/null || :
|
||||
fi
|
||||
|
||||
# Configure Postgresql. Do this after the API is stopped. Never fatal: a
|
||||
# repair/upgrade must complete its system-level work even when the database
|
||||
# is down (e.g. it is the reboot after this repair that revives Postgres).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue