From 58cd77cae4f4f2786ac445a106873bae8fcb256e Mon Sep 17 00:00:00 2001 From: alexbelgium Date: Thu, 29 May 2025 16:48:55 +0200 Subject: [PATCH] upgrade --- postgres/config.json | 2 +- postgres/rootfs/etc/cont-init.d/99-run.sh | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/postgres/config.json b/postgres/config.json index b6a376d44..72e432f89 100644 --- a/postgres/config.json +++ b/postgres/config.json @@ -39,5 +39,5 @@ "slug": "postgres", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres", - "version": "15.7-37" + "version": "15.7-37_test2" } diff --git a/postgres/rootfs/etc/cont-init.d/99-run.sh b/postgres/rootfs/etc/cont-init.d/99-run.sh index 78db855d0..2e3484601 100755 --- a/postgres/rootfs/etc/cont-init.d/99-run.sh +++ b/postgres/rootfs/etc/cont-init.d/99-run.sh @@ -11,9 +11,14 @@ PG_MAJOR_VERSION="${PG_MAJOR:-15}" RESTART_FLAG_FILE="$CONFIG_HOME/restart_needed" # Ensure permissions and folder structure + mkdir -p "$PGDATA" -chown -R postgres:postgres "$PGDATA" -chmod 700 "$PGDATA" + +fix_permissions(){ + chown -R postgres:postgres "$PGDATA" + chmod 700 "$PGDATA" +} + chmod -R 755 "$CONFIG_HOME" RESTART_NEEDED=false @@ -70,6 +75,8 @@ upgrade_postgres_if_needed() { exit 1 fi + fix_permissions + # Start old Postgres bashio::log.info "Starting old Postgres ($CLUSTER_VERSION) to capture encoding/locale settings" su - postgres -c "$BINARIES_DIR/$CLUSTER_VERSION/bin/pg_ctl -w -D '$PGDATA' start" @@ -84,6 +91,8 @@ upgrade_postgres_if_needed() { bashio::log.info "Stopping old Postgres ($CLUSTER_VERSION)" su - postgres -c "$BINARIES_DIR/$CLUSTER_VERSION/bin/pg_ctl -w -D '$PGDATA' stop" + fix_permissions + # Move aside data directory rm -rf "$PGDATA" @@ -91,6 +100,8 @@ upgrade_postgres_if_needed() { bashio::log.info "Initializing new data cluster for $IMAGE_VERSION" su - postgres -c "$BINARIES_DIR/$IMAGE_VERSION/bin/initdb --encoding=$ENCODING --lc-collate=$LC_COLLATE --lc-ctype=$LC_CTYPE -D '$PGDATA'" + fix_permissions + # Upgrade using pg_upgrade bashio::log.info "Running pg_upgrade from $CLUSTER_VERSION → $IMAGE_VERSION" chmod 700 "$PGDATA"