From e5ce9859e657ce7c6e6f778930d05dff4386cea7 Mon Sep 17 00:00:00 2001 From: Pablo Zmdl Date: Fri, 29 May 2026 14:30:03 +0200 Subject: [PATCH] Properly compare version numbers Signed-off-by: Pablo Zmdl --- Containers/nextcloud/upgrade-latest-major.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Containers/nextcloud/upgrade-latest-major.sh b/Containers/nextcloud/upgrade-latest-major.sh index f1f2e0df..f57c42a0 100644 --- a/Containers/nextcloud/upgrade-latest-major.sh +++ b/Containers/nextcloud/upgrade-latest-major.sh @@ -7,7 +7,7 @@ fi # shellcheck disable=SC2016 image_version="$($PHP_CLI -r 'require "/var/www/html/version.php"; echo implode(".", $OC_Version);')" -IMAGE_MAJOR="${image_version%%.*}" +export IMAGE_MAJOR="${image_version%%.*}" $PHP_CLI /var/www/html/occ config:system:set updatedirectory --value="/nc-updater" INSTALLED_AT="$($PHP_CLI /var/www/html/occ config:app:get core installedat)" @@ -25,9 +25,9 @@ if ! $PHP_CLI /var/www/html/occ -V || $PHP_CLI /var/www/html/occ status | grep m fi # shellcheck disable=SC2016 installed_version="$($PHP_CLI -r 'require "/var/www/html/version.php"; echo implode(".", $OC_Version);')" -INSTALLED_MAJOR="${installed_version%%.*}" +export INSTALLED_MAJOR="${installed_version%%.*}" # If a valid upgrade path, trigger the Nextcloud built-in Updater -if ! [ "$INSTALLED_MAJOR" -gt "$IMAGE_MAJOR" ]; then +if ! $PHP_CLI -r "version_compare(getenv('INSTALLED_MAJOR'), getenv('IMAGE_MAJOR'), '>') || exit(1);"; then $PHP_CLI /var/www/html/updater/updater.phar --no-interaction --no-backup if ! $PHP_CLI /var/www/html/occ -V || $PHP_CLI /var/www/html/occ status | grep maintenance | grep -q 'true'; then echo "Installation of Nextcloud failed!"