Преглед изворни кода

move detect_major_update func to core submodule

DerLinkman пре 1 месец
родитељ
комит
7067e2c714
2 измењених фајлова са 44 додато и 65 уклоњено
  1. 44 0
      _modules/scripts/core.sh
  2. 0 65
      update.sh

+ 44 - 0
_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
 }

+ 0 - 65
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