diff --git a/nextcloud/actions/get-version b/nextcloud/actions/get-version new file mode 100755 index 0000000..32a3f00 --- /dev/null +++ b/nextcloud/actions/get-version @@ -0,0 +1,24 @@ +#!/bin/bash +# compose: no-hooks + +. $CHARM_PATH/lib/common + + + + +image_version=${DOCKER_BASE_IMAGE##*:} ## retrieve tag +image_version=${image_version%%-*} ## remove suffix + +version=$(nextcloud:config:version) || { + err "Failed to retrieve version" + exit 1 +} + +version=${version:-N/A} ## remove suffix + +msg=() +if [ "$version" != "$image_version" ]; then + msg+=("image version mismatch ($image_version)") +fi + +printf "%s\n" "$version" "${msg[@]}" diff --git a/nextcloud/actions/upgrade b/nextcloud/actions/upgrade index 86c0241..369b60c 100755 --- a/nextcloud/actions/upgrade +++ b/nextcloud/actions/upgrade @@ -55,17 +55,7 @@ while [ "$1" ]; do shift done -nextcloud:config:version() { - for f in {"$SERVICE_CONFIGSTORE","$SERVICE_DATASTORE"}/var/www/html/config/config.php; do - if [ -e "$f" ]; then - cat "$f" - break - fi - done | - grep "'version' =>" | - cut -f 4 -d \' | - cut -f 1-3 -d . -} +. lib/common nextcloud:code:version() { cat "$SERVICE_DATASTORE/var/www/html/version.php" | diff --git a/nextcloud/lib/common b/nextcloud/lib/common index 34b494b..abd19bd 100644 --- a/nextcloud/lib/common +++ b/nextcloud/lib/common @@ -188,4 +188,17 @@ nextcloud:config:simple:add() { fi ## Add '$key' => 'value', to the end of the file, before the closing paren. sed -ri "s/^(\);)$/ '$key' => '${value}',\n\1/g" "$CONFIGFILE" -} \ No newline at end of file +} + + +nextcloud:config:version() { + for f in {"$SERVICE_CONFIGSTORE","$SERVICE_DATASTORE"}/var/www/html/config/config.php; do + if [ -e "$f" ]; then + cat "$f" + break + fi + done | + grep "'version' =>" | + cut -f 4 -d \' | + cut -f 1-3 -d . +}