From cee27645ea1e078d233c9857987d16b0fe3033ed Mon Sep 17 00:00:00 2001 From: Nathan Fretz Date: Tue, 6 Aug 2024 12:32:45 +1000 Subject: [PATCH] Update Nextcloud to v29.0.4 (#1297) --- nextcloud/docker-compose.yml | 6 ++--- nextcloud/hooks/post-update | 44 ++++++++++++++++++++++++++++++++++++ nextcloud/hooks/pre-start | 9 ++++++-- nextcloud/umbrel-app.yml | 10 +++++--- 4 files changed, 61 insertions(+), 8 deletions(-) create mode 100755 nextcloud/hooks/post-update diff --git a/nextcloud/docker-compose.yml b/nextcloud/docker-compose.yml index 0cfd6f07e..3e71ba740 100644 --- a/nextcloud/docker-compose.yml +++ b/nextcloud/docker-compose.yml @@ -28,7 +28,7 @@ services: - "${APP_DATA_DIR}/data/redis:/data" web: - image: nextcloud:28.0.3-apache@sha256:ed07f89119dcca2a3711897c48a8ac969542d96d69384445d8fcdc7804ca946f + image: nextcloud:29.0.4-apache@sha256:12c7bb0da1d41a08583971d5ba9771c4f37592ddd0aae5f5ce6a306961caa674 # Currently needs to be run as root, if we run as uid 1000 this fails # https://github.com/nextcloud/docker/blob/05026b029d37fc5cd488d4a4a2a79480e39841ba/21.0/apache/entrypoint.sh#L53-L77 # user: "1000:1000" @@ -44,14 +44,14 @@ services: - TRUSTED_PROXIES="${NETWORK_IP}/16" - NEXTCLOUD_ADMIN_USER=umbrel - NEXTCLOUD_ADMIN_PASSWORD=${APP_PASSWORD} - - NEXTCLOUD_TRUSTED_DOMAINS=${APP_DOMAIN}:${APP_NEXTCLOUD_PORT} ${APP_HIDDEN_SERVICE} ${DEVICE_HOSTNAME}:${APP_NEXTCLOUD_PORT} ${APP_NEXTCLOUD_LOCAL_IPS} + - NEXTCLOUD_TRUSTED_DOMAINS=${APP_DOMAIN}:${APP_NEXTCLOUD_PORT} ${APP_HIDDEN_SERVICE} ${DEVICE_HOSTNAME}:${APP_NEXTCLOUD_PORT} ${APP_NEXTCLOUD_LOCAL_IPS} nextcloud_web_1 - PHP_UPLOAD_LIMIT=1024G depends_on: - db - redis cron: - image: nextcloud:28.0.3-apache@sha256:ed07f89119dcca2a3711897c48a8ac969542d96d69384445d8fcdc7804ca946f + image: nextcloud:29.0.4-apache@sha256:12c7bb0da1d41a08583971d5ba9771c4f37592ddd0aae5f5ce6a306961caa674 # Currently needs to be run as root, if we run as uid 1000 this fails # https://github.com/nextcloud/docker/blob/05026b029d37fc5cd488d4a4a2a79480e39841ba/21.0/apache/entrypoint.sh#L53-L77 # user: "1000:1000" diff --git a/nextcloud/hooks/post-update b/nextcloud/hooks/post-update new file mode 100755 index 000000000..f9ce6b0ac --- /dev/null +++ b/nextcloud/hooks/post-update @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +set -euo pipefail + +# This script checks the Nextcloud config.php file for the presence of 'nextcloud_web_1' in the trusted_domains array and adds it if it doesn't exist. Pre-29.0.4 installs on umbrelOS will not have the domain added via `NEXTCLOUD_TRUSTED_DOMAIN`. +# This is handled in a post-update hook to make sure we don't interfere with the Nextcloud startup process and pre-start script where config.php is being written to. + +APP_DATA_DIR="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/..)" +CONFIG_PHP_FILE="${APP_DATA_DIR}/data/nextcloud/config/config.php" + +DOMAIN_TO_ADD="nextcloud_web_1" + +domain_exists() { + grep -q "'$DOMAIN_TO_ADD'" "$CONFIG_PHP_FILE" +} + +get_highest_index() { + awk -F "=>" '/trusted_domains/ { + max = 0 + while (getline && !/\),/) { + if ($1 ~ /^[[:space:]]*[0-9]+/) { + split($1, a, " ") + if (a[1] > max) max = a[1] + } + } + print max + }' "$CONFIG_PHP_FILE" +} + +if domain_exists; then + echo "Domain '$DOMAIN_TO_ADD' already exists in trusted_domains." +else + echo "Domain '$DOMAIN_TO_ADD' not found. Adding it to trusted_domains..." + + # Get the highest current index in the trusted_domains array + highest_index=$(get_highest_index) + + # Calculate the new index to add + new_index=$((highest_index + 1)) + + # Add the new domain entry + sed -i "/trusted_domains/,/),/ s/),/ $new_index => '$DOMAIN_TO_ADD',\n&/" "$CONFIG_PHP_FILE" + + echo "Domain '$DOMAIN_TO_ADD' added successfully." +fi \ No newline at end of file diff --git a/nextcloud/hooks/pre-start b/nextcloud/hooks/pre-start index c1f7bc42c..2e2f92422 100755 --- a/nextcloud/hooks/pre-start +++ b/nextcloud/hooks/pre-start @@ -9,6 +9,8 @@ CONFIG_PHP_FILE="${APP_DATA_DIR}/data/nextcloud/config/config.php" APP_COMPOSE_FILE="${APP_DATA_DIR}/docker-compose.yml" APP_COMPOSE_BACKUP_FILE="${APP_DATA_DIR}/docker-compose.yml.bak" +# TODO: When Nextcloud 30 is released, refactor this script to handle updates from all patch versions released to the umbrel app store. + # Supported list of Nextcloud migrations VERSIONS=() VERSIONS+=( "22.1.1.2" ) @@ -18,7 +20,9 @@ VERSIONS+=( "24.0.7.1" ) VERSIONS+=( "25.0.1.1" ) VERSIONS+=( "26.0.9.1" ) VERSIONS+=( "27.0.2.1" ) -VERSIONS+=( "28.0.0.11" ) +VERSIONS+=( "28.0.3.2" ) +VERSIONS+=( "29.0.4.1" ) + IMAGES=() IMAGES+=( "nextcloud:22.1.1-apache@sha256:99d94124b2024c9f7f38dc12144a92bc0d68d110bcfd374169ebb7e8df0adf8e" ) @@ -28,7 +32,8 @@ IMAGES+=( "nextcloud:24.0.7-apache@sha256:f95a21b598b7470b788251db5b0bbe9516992f IMAGES+=( "nextcloud:25.0.1-apache@sha256:a200319b132c01ec3486e0dcaf052092b560ec30ac9b78115607696dd201f704" ) IMAGES+=( "nextcloud:26.0.9-apache@sha256:23180fbe8169d428ce0058bfc8d47793628a16e00e40b495d82e4504a124b3fa" ) IMAGES+=( "nextcloud:27.0.2-apache@sha256:3c8040278bdc991cbc025278eaffc4978a9c2fd4ac34e95b10f646dcadb7c3fb" ) -IMAGES+=( "nextcloud:28.0.0-apache@sha256:0d3dcb01cfff7775873a4f50768c3561c956bfeab9be59647754d9c1fe88b14c" ) +IMAGES+=( "nextcloud:28.0.3-apache@sha256:ed07f89119dcca2a3711897c48a8ac969542d96d69384445d8fcdc7804ca946f" ) +IMAGES+=( "nextcloud:29.0.4-apache@sha256:12c7bb0da1d41a08583971d5ba9771c4f37592ddd0aae5f5ce6a306961caa674" ) find_index() { local -r value="${1}" diff --git a/nextcloud/umbrel-app.yml b/nextcloud/umbrel-app.yml index c6bff34b1..1636c5ce8 100644 --- a/nextcloud/umbrel-app.yml +++ b/nextcloud/umbrel-app.yml @@ -2,7 +2,7 @@ manifestVersion: 1.1 id: nextcloud category: files name: Nextcloud -version: "28.0.3" +version: "29.0.4" tagline: Productivity platform that keeps you in control description: >- Nextcloud puts your data at your fingertips, under your control. @@ -25,9 +25,13 @@ description: >- Note: After logging in to Nextcloud please change the password to something secure before sharing the address with anyone. releaseNotes: >- - This patch update takes Nextcloud from version 28.0.2 to 28.0.3 and is a minor update that includes many changes/fixes. + This is a major upgrade of Nextcloud on umbrelOS, updating from version 28.0.3 to 29.0.4. The Nextcloud app on the Umbrel app store will now receive updates in alignment with the official Nextcloud release schedule. - Full release details for all Nextcloud versions can be found at https://nextcloud.com/changelog/ + + This update may take several minutes to complete. Nextcloud may be unavailable for a few minutes during the update process. + + + Full release notes can be found at https://github.com/nextcloud/server/releases developer: Nextcloud GmbH website: https://nextcloud.com dependencies: []