Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias K <3knoeppl@informatik.uni-hamburg.de>2019-01-08 10:43:30 +0300
committernachoparker <nacho@ownyourbits.com>2019-01-08 10:43:30 +0300
commit7ead0f0ad40ca48d803b848932ef95c1a6bf2d3a (patch)
tree167343083ee10f670aa1aba0e3259f72c347d9aa /bin/ncp-update-nc
parentdb8ded640ab3c6e0e3a86bfe874c9d67f65846c5 (diff)
nc-update-nc: check app compatibility before before executing NC update (#682)
Diffstat (limited to 'bin/ncp-update-nc')
-rwxr-xr-xbin/ncp-update-nc55
1 files changed, 55 insertions, 0 deletions
diff --git a/bin/ncp-update-nc b/bin/ncp-update-nc
index 273f568a..53944fdc 100755
--- a/bin/ncp-update-nc
+++ b/bin/ncp-update-nc
@@ -61,6 +61,61 @@ echo "Current Nextcloud version $CURRENT"
echo "Available Nextcloud version $VER"
[[ "$NEED_UPDATE" == "true" ]] || { echo "Nothing to update"; exit 1; }
+
+# app compatibility check
+##########################
+
+incompatibleApps=""
+
+#for a in a b c; do echo $a; done
+for jsonWord in $(ncc app:list --output="json_pretty" | grep \"disabled\": -B5000 | grep " ")
+do
+ appQuoteStripped=${jsonWord//\"}
+ app=${appQuoteStripped//:}
+
+ # if line ends in ':' and app directory exist -> app is valid; else skip current app
+ [[ -z "${appQuoteStripped##*:}" && -d "/var/www/nextcloud/apps/$app" ]] || continue
+
+ appDir=nextcloud/apps/$app
+ appInfoPath=$appDir/appinfo/info.xml
+ [[ -f "$appInfoPath" ]] || { echo "ERROR: info.xml not found for $app (searching in '$appInfoPath')!"; exit 1; }
+
+ versionXML=$(grep "$appInfoPath" -e '< *nextcloud *min-version="[0-9][0-9]*" *max-version="[0-9][0-9]*" */>' | tr -d "\n")
+ for word in $versionXML
+ do
+ minGrep=$(grep -o 'min-version="[0-9][0-9]*"' <<< $word | sed "s/min-version=\"//")
+ maxGrep=$(grep -o 'max-version="[0-9][0-9]*"' <<< $word | sed "s/max-version=\"//")
+
+ if [[ ! -z "$minGrep" ]]; then
+ minVersion="${minGrep//\"}"
+ fi
+ if [[ ! -z "$maxGrep" ]]; then
+ maxVersion="${maxGrep//\"}"
+ fi
+
+ done
+
+ # verify min and max version are numbers
+ [[ ! -z "$minVersion" && ! -z "$maxVersion" && "$minVersion" -eq "$minVersion" && "$maxVersion" -eq "$maxVersion" ]] || {
+ echo "ERROR: Malformed compatibility info (min/max version) for app '$app'!"
+ exit 1
+ }
+
+ if [[ "$MAJOR" -lt "$minVersion" || "$MAJOR" -gt "$maxVersion" ]]; then
+ incompatibleApps="$incompatibleApps$app (requires NC $minVersion-$maxVersion), "
+ fi
+
+done
+
+if [ "$incompatibleApps" != "" ]; then
+ echo "1 or more apps are not compatible with the latest Nextcloud version! Update will be held back..."
+ echo "Not compatible: ${incompatibleApps%, }"
+ exit 1
+else
+ echo "All apps are compatible with the new NC version. Proceeding..."
+fi
+
+
# make sure that cron.php is not running and there are no pending jobs
# https://github.com/nextcloud/server/issues/10949
pgrep -cf cron.php &>/dev/null && { pkill -f cron.php; sleep 3; }