diff --git a/_modules/scripts/core.sh b/_modules/scripts/core.sh index d0615a961..3728f5fb3 100644 --- a/_modules/scripts/core.sh +++ b/_modules/scripts/core.sh @@ -176,4 +176,48 @@ in_array() { shift for e; do [[ "$e" == "$match" ]] && return 0; done return 1 +} + +detect_major_update() { + if [ ${BRANCH} == "master" ]; then + # Array with major versions + # Add major versions here + MAJOR_VERSIONS=( + "2025-02" + "2025-03" + ) + + current_version="" + if [[ -f "${SCRIPT_DIR}/data/web/inc/app_info.inc.php" ]]; then + current_version=$(grep 'MAILCOW_GIT_VERSION' ${SCRIPT_DIR}/data/web/inc/app_info.inc.php | sed -E 's/.*MAILCOW_GIT_VERSION="([^"]+)".*/\1/') + fi + if [[ -z "$current_version" ]]; then + return 1 + fi + 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 "\nPlease read the release notes before proceeding." + 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 } \ No newline at end of file diff --git a/update.sh b/update.sh index d3252863b..a300e99a9 100755 --- a/update.sh +++ b/update.sh @@ -19,71 +19,6 @@ source _modules/scripts/ipv6_controller.sh source _modules/scripts/new_options.sh source _modules/scripts/migrate_options.sh -detect_major_update() { - if [ ${BRANCH} == "master" ]; then - # Array with major versions - # Add major versions here - MAJOR_VERSIONS=( - "2025-02" - "2025-03" - ) - - current_version="" - if [[ -f "${SCRIPT_DIR}/data/web/inc/app_info.inc.php" ]]; then - current_version=$(grep 'MAILCOW_GIT_VERSION' ${SCRIPT_DIR}/data/web/inc/app_info.inc.php | sed -E 's/.*MAILCOW_GIT_VERSION="([^"]+)".*/\1/') - fi - if [[ -z "$current_version" ]]; then - return 1 - fi - 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 "\nPlease read the release notes before proceeding." - 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 -} - -remove_obsolete_options() { - OBSOLETE_OPTIONS=( - "ACME_CONTACT" - ) - - for option in "${OBSOLETE_OPTIONS[@]}"; do - if [[ "$option" == "ACME_CONTACT" ]]; then - sed -i '/^# Lets Encrypt registration contact information/d' mailcow.conf - sed -i "/^# Let's Encrypt registration contact information/d" mailcow.conf - sed -i '/^# Optional: Leave empty for none/d' mailcow.conf - sed -i '/^# This value is only used on first order!/d' mailcow.conf - sed -i '/^# Setting it at a later point will require the following steps:/d' mailcow.conf - sed -i '/^# https:\/\/docs.mailcow.email\/troubleshooting\/debug-reset_tls\//d' mailcow.conf - sed -i '/^ACME_CONTACT=.*/d' mailcow.conf - sed -i '/^#ACME_CONTACT=.*/d' mailcow.conf - else - sed -i "/^${option}=.*/d" mailcow.conf - sed -i "/^#${option}=.*/d" mailcow.conf - fi - done -} ############## End Function Section ############## # Check permissions