diff --git a/nextcloud/actions/upgrade b/nextcloud/actions/upgrade index ca5b98f..41a4c29 100755 --- a/nextcloud/actions/upgrade +++ b/nextcloud/actions/upgrade @@ -120,6 +120,19 @@ for v in "${last_available_versions[@]}"; do fi done +docker_version=$(docker info --format '{{.ServerVersion}}') +last_compatible_versions=() +for v in "${last_upgradable_versions[@]}"; do + if version_gt "$docker_version" 20.10.0; then + last_compatible_versions+=("$v") + continue + fi + if version_gt "26.99.99" "$v"; then + last_compatible_versions+=("$v") + fi +done + + if [ "${#last_upgradable_versions[@]}" == 0 ]; then info "${DARKYELLOW}nextcloud${NORMAL} is already ${GREEN}up-to-date${NORMAL}." exit 0 @@ -130,7 +143,7 @@ if [ -z "$target" ]; then target=${last_upgradable_versions[0]} else if [[ " ${last_available_versions[*]} " != *" $target "* ]]; then - err "Invalid version $target selected, please specify one of:" + err "Invalid version ${WHITE}$target${NORMAL} selected, please specify one of:" for v in "${last_upgradable_versions[@]}"; do echo " - $v" done >&2 @@ -139,6 +152,16 @@ else info "Target version ${WHITE}$target${NORMAL}" fi +if [[ " ${last_compatible_versions[*]} " != *" $target "* ]]; then + err "Sorry, ${DARKYELLOW}$SERVICE_NAME${NORMAL} ${WHITE}$target${NORMAL}" \ + "require docker version >= ${WHITE}20.10${NORMAL} (current: $docker_version)" + echo " Nextcloud versions <= ${WHITE}27${NORMAL} are still supported." >&2 + echo " You can specify one of:" >&2 + for v in "${last_compatible_versions[@]}"; do + echo " - $v" >&2 + done + exit 1 +fi upgrade_path=($(echo "${last_upgradable_versions[*]}" | tr ' ' '\n' | uniq -w 3 | sort -V))