From bdacca1931461e6b71af6c74dc0c97c622dbde37 Mon Sep 17 00:00:00 2001 From: Alexander Zubarev Date: Wed, 30 Sep 2026 12:53:21 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20scripts/deploy-nextcloud.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/deploy-nextcloud.sh | 56 +++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/scripts/deploy-nextcloud.sh b/scripts/deploy-nextcloud.sh index 140579a..d0166c5 100755 --- a/scripts/deploy-nextcloud.sh +++ b/scripts/deploy-nextcloud.sh @@ -296,32 +296,70 @@ OLD_IMAGE="$( # ============================================================ -# Detect actual current Nextcloud version +# Detect current Nextcloud status/version +# +# Use OCC instead of reading version.php directly. +# OCC is the supported machine-readable interface and also +# verifies that the currently running installation can load. # ============================================================ log "Detect current Nextcloud version" -CURRENT_NC_VERSION="$( + +set +e + +CURRENT_STATUS_JSON="$( docker exec \ + -u www-data \ nextcloud \ - php -r ' - require "/var/www/html/version.php"; - echo implode(".", $OC_Version); - ' + php occ status \ + --output=json \ + 2>&1 +)" + +CURRENT_STATUS_RC=$? + +set -e + + +if [[ "${CURRENT_STATUS_RC}" -ne 0 ]] +then + + echo + echo "--- OCC status output ---" + echo "${CURRENT_STATUS_JSON}" + + fail \ + "Could not get current Nextcloud status (exit code ${CURRENT_STATUS_RC})" + +fi + + +CURRENT_NC_VERSION="$( + printf '%s\n' "${CURRENT_STATUS_JSON}" | + sed -nE \ + 's/.*"versionstring"[[:space:]]*:[[:space:]]*"([^"]+)".*/\1/p' | + head -n1 )" -[[ -n "${CURRENT_NC_VERSION}" ]] || \ +[[ -n "${CURRENT_NC_VERSION}" ]] || { + + echo + echo "OCC output:" + echo "${CURRENT_STATUS_JSON}" + fail "Could not determine current Nextcloud version" +} -echo "Current Docker image:" + +echo "Current image:" echo " ${OLD_IMAGE}" echo "Current Nextcloud version:" echo " ${CURRENT_NC_VERSION}" - # ============================================================ # Pull target Nextcloud image #