mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-05-21 16:21:51 +02:00
upgrade
This commit is contained in:
@@ -39,5 +39,5 @@
|
|||||||
"slug": "postgres",
|
"slug": "postgres",
|
||||||
"udev": true,
|
"udev": true,
|
||||||
"url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres",
|
"url": "https://github.com/alexbelgium/hassio-addons/tree/master/postgres",
|
||||||
"version": "15.7-37"
|
"version": "15.7-37_test2"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,14 @@ PG_MAJOR_VERSION="${PG_MAJOR:-15}"
|
|||||||
RESTART_FLAG_FILE="$CONFIG_HOME/restart_needed"
|
RESTART_FLAG_FILE="$CONFIG_HOME/restart_needed"
|
||||||
|
|
||||||
# Ensure permissions and folder structure
|
# Ensure permissions and folder structure
|
||||||
|
|
||||||
mkdir -p "$PGDATA"
|
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"
|
chmod -R 755 "$CONFIG_HOME"
|
||||||
|
|
||||||
RESTART_NEEDED=false
|
RESTART_NEEDED=false
|
||||||
@@ -70,6 +75,8 @@ upgrade_postgres_if_needed() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
fix_permissions
|
||||||
|
|
||||||
# Start old Postgres
|
# Start old Postgres
|
||||||
bashio::log.info "Starting old Postgres ($CLUSTER_VERSION) to capture encoding/locale settings"
|
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"
|
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)"
|
bashio::log.info "Stopping old Postgres ($CLUSTER_VERSION)"
|
||||||
su - postgres -c "$BINARIES_DIR/$CLUSTER_VERSION/bin/pg_ctl -w -D '$PGDATA' stop"
|
su - postgres -c "$BINARIES_DIR/$CLUSTER_VERSION/bin/pg_ctl -w -D '$PGDATA' stop"
|
||||||
|
|
||||||
|
fix_permissions
|
||||||
|
|
||||||
# Move aside data directory
|
# Move aside data directory
|
||||||
rm -rf "$PGDATA"
|
rm -rf "$PGDATA"
|
||||||
|
|
||||||
@@ -91,6 +100,8 @@ upgrade_postgres_if_needed() {
|
|||||||
bashio::log.info "Initializing new data cluster for $IMAGE_VERSION"
|
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'"
|
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
|
# Upgrade using pg_upgrade
|
||||||
bashio::log.info "Running pg_upgrade from $CLUSTER_VERSION → $IMAGE_VERSION"
|
bashio::log.info "Running pg_upgrade from $CLUSTER_VERSION → $IMAGE_VERSION"
|
||||||
chmod 700 "$PGDATA"
|
chmod 700 "$PGDATA"
|
||||||
|
|||||||
Reference in New Issue
Block a user