From 787fa49d0c060da5d330d1f104ff7bae666754b0 Mon Sep 17 00:00:00 2001 From: FreddleSpl0it Date: Tue, 25 Feb 2025 12:08:21 +0100 Subject: [PATCH] prompt user before applying major updates --- update.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/update.sh b/update.sh index c11179c5e..94ffaf698 100755 --- a/update.sh +++ b/update.sh @@ -710,6 +710,43 @@ migrate_solr_config_options() { fi } +detect_major_update() { + if [ ${BRANCH} == "master" ]; then + # Array with major versions + # Add major versions here + MAJOR_VERSIONS=( + ) + + current_version=$(git describe --tags $(git rev-list --tags --max-count=1)) + release_url="https://github.com/mailcow/mailcow-dockerized/releases/tag" + + updates_to_apply=() + + for version in "${MAJOR_VERSIONS[@]}"; do + if [[ "$current_version" < "$version" ]]; then + updates_to_apply+=("$version") + fi + done + + if [[ ${#updates_to_apply[@]} -gt 0 ]]; then + echo -e "\e[33m\nMAJOR UPDATES to be applied:\e[0m" + for update in "${updates_to_apply[@]}"; do + echo "$update - $release_url/$update" + done + + echo -e "\n⚠️ Please read the release notes before proceeding.\n" + + read -p "Do you want to proceed with the update? [y/n] " response + if [[ "${response}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then + echo "Proceeding with the update..." + else + echo "Update canceled. Exiting." + exit 1 + fi + fi + fi +} + ############## End Function Section ############## # Check permissions @@ -1345,6 +1382,7 @@ if [ ! "$FORCE" ]; then echo "OK, exiting." exit 0 fi + detect_major_update migrate_docker_nat fi