Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 3 | ############## Begin Function Section ############## |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 4 | |
| 5 | check_online_status() { |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 6 | CHECK_ONLINE_DOMAINS=('https://github.com' 'https://hub.docker.com') |
| 7 | for domain in "${CHECK_ONLINE_DOMAINS[@]}"; do |
| 8 | if timeout 6 curl --head --silent --output /dev/null ${domain}; then |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 9 | return 0 |
| 10 | fi |
| 11 | done |
| 12 | return 1 |
| 13 | } |
| 14 | |
| 15 | prefetch_images() { |
| 16 | [[ -z ${BRANCH} ]] && { echo -e "\e[33m\nUnknown branch...\e[0m"; exit 1; } |
| 17 | git fetch origin #${BRANCH} |
| 18 | while read image; do |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 19 | if [[ "${image}" == "robbertkl/ipv6nat" ]]; then |
| 20 | if ! grep -qi "ipv6nat-mailcow" docker-compose.yml || grep -qi "enable_ipv6: false" docker-compose.yml; then |
| 21 | continue |
| 22 | fi |
| 23 | fi |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 24 | RET_C=0 |
| 25 | until docker pull ${image}; do |
| 26 | RET_C=$((RET_C + 1)) |
| 27 | echo -e "\e[33m\nError pulling $image, retrying...\e[0m" |
| 28 | [ ${RET_C} -gt 3 ] && { echo -e "\e[31m\nToo many failed retries, exiting\e[0m"; exit 1; } |
| 29 | sleep 1 |
| 30 | done |
| 31 | done < <(git show origin/${BRANCH}:docker-compose.yml | grep "image:" | awk '{ gsub("image:","", $3); print $2 }') |
| 32 | } |
| 33 | |
| 34 | docker_garbage() { |
| 35 | IMGS_TO_DELETE=() |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 36 | for container in $(grep -oP "image: \Kmailcow.+" "${SCRIPT_DIR}/docker-compose.yml"); do |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 37 | REPOSITORY=${container/:*} |
| 38 | TAG=${container/*:} |
| 39 | V_MAIN=${container/*.} |
| 40 | V_SUB=${container/*.} |
| 41 | EXISTING_TAGS=$(docker images | grep ${REPOSITORY} | awk '{ print $2 }') |
| 42 | for existing_tag in ${EXISTING_TAGS[@]}; do |
| 43 | V_MAIN_EXISTING=${existing_tag/*.} |
| 44 | V_SUB_EXISTING=${existing_tag/*.} |
| 45 | # Not an integer |
| 46 | [[ ! $V_MAIN_EXISTING =~ ^[0-9]+$ ]] && continue |
| 47 | [[ ! $V_SUB_EXISTING =~ ^[0-9]+$ ]] && continue |
| 48 | |
| 49 | if [[ $V_MAIN_EXISTING == "latest" ]]; then |
| 50 | echo "Found deprecated label \"latest\" for repository $REPOSITORY, it should be deleted." |
| 51 | IMGS_TO_DELETE+=($REPOSITORY:$existing_tag) |
| 52 | elif [[ $V_MAIN_EXISTING -lt $V_MAIN ]]; then |
| 53 | echo "Found tag $existing_tag for $REPOSITORY, which is older than the current tag $TAG and should be deleted." |
| 54 | IMGS_TO_DELETE+=($REPOSITORY:$existing_tag) |
| 55 | elif [[ $V_SUB_EXISTING -lt $V_SUB ]]; then |
| 56 | echo "Found tag $existing_tag for $REPOSITORY, which is older than the current tag $TAG and should be deleted." |
| 57 | IMGS_TO_DELETE+=($REPOSITORY:$existing_tag) |
| 58 | fi |
| 59 | done |
| 60 | done |
| 61 | |
| 62 | if [[ ! -z ${IMGS_TO_DELETE[*]} ]]; then |
| 63 | echo "Run the following command to delete unused image tags:" |
| 64 | echo |
| 65 | echo " docker rmi ${IMGS_TO_DELETE[*]}" |
| 66 | echo |
| 67 | if [ ! $FORCE ]; then |
| 68 | read -r -p "Do you want to delete old image tags right now? [y/N] " response |
| 69 | if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then |
| 70 | docker rmi ${IMGS_TO_DELETE[*]} |
| 71 | else |
| 72 | echo "OK, skipped." |
| 73 | fi |
| 74 | else |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 75 | echo "Running image removal without extra confirmation due to force mode." |
| 76 | docker rmi ${IMGS_TO_DELETE[*]} |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 77 | fi |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 78 | echo -e "\e[32mFurther cleanup...\e[0m" |
| 79 | echo "If you want to cleanup further garbage collected by Docker, please make sure all containers are up and running before cleaning your system by executing \"docker system prune\"" |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 80 | fi |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 81 | } |
| 82 | |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 83 | in_array() { |
| 84 | local e match="$1" |
| 85 | shift |
| 86 | for e; do [[ "$e" == "$match" ]] && return 0; done |
| 87 | return 1 |
| 88 | } |
| 89 | |
| 90 | migrate_docker_nat() { |
| 91 | NAT_CONFIG='{"ipv6":true,"fixed-cidr-v6":"fd00:dead:beef:c0::/80","experimental":true,"ip6tables":true}' |
| 92 | # Min Docker version |
| 93 | DOCKERV_REQ=20.10.2 |
| 94 | # Current Docker version |
| 95 | DOCKERV_CUR=$(docker version -f '{{.Server.Version}}') |
| 96 | if grep -qi "ipv6nat-mailcow" docker-compose.yml && grep -qi "enable_ipv6: true" docker-compose.yml; then |
| 97 | echo -e "\e[32mNative IPv6 implementation available.\e[0m" |
| 98 | echo "This will enable experimental features in the Docker daemon and configure Docker to do the IPv6 NATing instead of ipv6nat-mailcow." |
| 99 | echo '!!! This step is recommended !!!' |
| 100 | echo "mailcow will try to roll back the changes if starting Docker fails after modifying the daemon.json configuration file." |
| 101 | read -r -p "Should we try to enable the native IPv6 implementation in Docker now (recommended)? [y/N] " dockernatresponse |
| 102 | if [[ ! "${dockernatresponse}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then |
| 103 | echo "OK, skipping this step." |
| 104 | return 0 |
| 105 | fi |
| 106 | fi |
| 107 | # Sort versions and check if we are running a newer or equal version to req |
| 108 | if [ $(printf "${DOCKERV_REQ}\n${DOCKERV_CUR}" | sort -V | tail -n1) == "${DOCKERV_CUR}" ]; then |
| 109 | # If Dockerd daemon json exists |
| 110 | if [ -s /etc/docker/daemon.json ]; then |
| 111 | IFS=',' read -r -a dockerconfig <<< $(cat /etc/docker/daemon.json | tr -cd '[:alnum:],') |
| 112 | if ! in_array ipv6true "${dockerconfig[@]}" || \ |
| 113 | ! in_array experimentaltrue "${dockerconfig[@]}" || \ |
| 114 | ! in_array ip6tablestrue "${dockerconfig[@]}" || \ |
| 115 | ! grep -qi "fixed-cidr-v6" /etc/docker/daemon.json; then |
| 116 | echo -e "\e[33mWarning:\e[0m You seem to have modified the /etc/docker/daemon.json configuration by yourself and not fully/correctly activated the native IPv6 NAT implementation." |
| 117 | echo "You will need to merge your existing configuration manually or fix/delete the existing daemon.json configuration before trying the update process again." |
| 118 | echo -e "Please merge the following content and restart the Docker daemon:\n" |
| 119 | echo ${NAT_CONFIG} |
| 120 | return 1 |
| 121 | fi |
| 122 | else |
| 123 | echo "Working on IPv6 NAT, please wait..." |
| 124 | echo ${NAT_CONFIG} > /etc/docker/daemon.json |
| 125 | ip6tables -F -t nat |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 126 | [[ -e /etc/alpine-release ]] && rc-service docker restart || systemctl restart docker.service |
| 127 | if [[ $? -ne 0 ]]; then |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 128 | echo -e "\e[31mError:\e[0m Failed to activate IPv6 NAT! Reverting and exiting." |
| 129 | rm /etc/docker/daemon.json |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 130 | if [[ -e /etc/alpine-release ]]; then |
| 131 | rc-service docker restart |
| 132 | else |
| 133 | systemctl reset-failed docker.service |
| 134 | systemctl restart docker.service |
| 135 | fi |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 136 | return 1 |
| 137 | fi |
| 138 | fi |
| 139 | # Removing legacy container |
| 140 | sed -i '/ipv6nat-mailcow:$/,/^$/d' docker-compose.yml |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 141 | if [ -s docker-compose.override.yml ]; then |
| 142 | sed -i '/ipv6nat-mailcow:$/,/^$/d' docker-compose.override.yml |
| 143 | if [[ "$(cat docker-compose.override.yml | sed '/^\s*$/d' | wc -l)" == "2" ]]; then |
| 144 | mv docker-compose.override.yml docker-compose.override.yml_backup |
| 145 | fi |
| 146 | fi |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 147 | echo -e "\e[32mGreat! \e[0mNative IPv6 NAT is active.\e[0m" |
| 148 | else |
| 149 | echo -e "\e[31mPlease upgrade Docker to version ${DOCKERV_REQ} or above.\e[0m" |
| 150 | return 0 |
| 151 | fi |
| 152 | } |
| 153 | |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 154 | remove_obsolete_nginx_ports() { |
| 155 | # Removing obsolete docker-compose.override.yml |
| 156 | for override in docker-compose.override.yml docker-compose.override.yaml; do |
| 157 | if [ -s $override ] ; then |
| 158 | if cat $override | grep nginx-mailcow > /dev/null 2>&1; then |
| 159 | if cat $override | grep -E '(\[::])' > /dev/null 2>&1; then |
| 160 | if cat $override | grep -w 80:80 > /dev/null 2>&1 && cat $override | grep -w 443:443 > /dev/null 2>&1 ; then |
| 161 | echo -e "\e[33mBacking up ${override} to preserve custom changes...\e[0m" |
| 162 | echo -e "\e[33m!!! Manual Merge needed (if other overrides are set) !!!\e[0m" |
| 163 | sleep 3 |
| 164 | cp $override ${override}_backup |
| 165 | sed -i '/nginx-mailcow:$/,/^$/d' $override |
| 166 | echo -e "\e[33mRemoved obsolete NGINX IPv6 Bind from original override File.\e[0m" |
| 167 | if [[ "$(cat $override | sed '/^\s*$/d' | wc -l)" == "2" ]]; then |
| 168 | mv $override ${override}_empty |
| 169 | echo -e "\e[31m${override} is empty. Renamed it to ensure mailcow is startable.\e[0m" |
| 170 | fi |
| 171 | fi |
| 172 | fi |
| 173 | fi |
| 174 | fi |
| 175 | done |
| 176 | } |
| 177 | |
| 178 | detect_docker_compose_command(){ |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame^] | 179 | if ! [[ "${DOCKER_COMPOSE_VERSION}" =~ ^(native|standalone)$ ]]; then |
| 180 | if docker compose > /dev/null 2>&1; then |
| 181 | if docker compose version --short | grep "2." > /dev/null 2>&1; then |
| 182 | DOCKER_COMPOSE_VERSION=native |
| 183 | COMPOSE_COMMAND="docker compose" |
| 184 | echo -e "\e[31mFound Docker Compose Plugin (native).\e[0m" |
| 185 | echo -e "\e[31mSetting the DOCKER_COMPOSE_VERSION Variable to native\e[0m" |
| 186 | sed -i 's/^DOCKER_COMPOSE_VERSION=.*/DOCKER_COMPOSE_VERSION=native/' $SCRIPT_DIR/mailcow.conf |
| 187 | sleep 2 |
| 188 | echo -e "\e[33mNotice: You'll have to update this Compose Version via your Package Manager manually!\e[0m" |
| 189 | else |
| 190 | echo -e "\e[31mCannot find Docker Compose with a Version Higher than 2.X.X.\e[0m" |
| 191 | echo -e "\e[31mPlease update/install it manually regarding to this doc site: https://docs.mailcow.email/i_u_m/i_u_m_install/\e[0m" |
| 192 | exit 1 |
| 193 | fi |
| 194 | elif docker-compose > /dev/null 2>&1; then |
| 195 | if ! [[ $(alias docker-compose 2> /dev/null) ]] ; then |
| 196 | if docker-compose version --short | grep "^2." > /dev/null 2>&1; then |
| 197 | DOCKER_COMPOSE_VERSION=standalone |
| 198 | COMPOSE_COMMAND="docker-compose" |
| 199 | echo -e "\e[31mFound Docker Compose Standalone.\e[0m" |
| 200 | echo -e "\e[31mSetting the DOCKER_COMPOSE_VERSION Variable to standalone\e[0m" |
| 201 | sed -i 's/^DOCKER_COMPOSE_VERSION=.*/DOCKER_COMPOSE_VERSION=standalone/' $SCRIPT_DIR/mailcow.conf |
| 202 | sleep 2 |
| 203 | echo -e "\e[33mNotice: For an automatic update of docker-compose please use the update_compose.sh scripts located at the helper-scripts folder.\e[0m" |
| 204 | else |
| 205 | echo -e "\e[31mCannot find Docker Compose with a Version Higher than 2.X.X.\e[0m" |
| 206 | echo -e "\e[31mPlease update/install regarding to this doc site: https://docs.mailcow.email/i_u_m/i_u_m_install/\e[0m" |
| 207 | exit 1 |
| 208 | fi |
| 209 | fi |
| 210 | |
| 211 | else |
| 212 | echo -e "\e[31mCannot find Docker Compose.\e[0m" |
| 213 | echo -e "\e[31mPlease install it regarding to this doc site: https://docs.mailcow.email/i_u_m/i_u_m_install/\e[0m" |
| 214 | exit 1 |
| 215 | fi |
| 216 | |
| 217 | elif [ "${DOCKER_COMPOSE_VERSION}" == "native" ]; then |
| 218 | COMPOSE_COMMAND="docker compose" |
| 219 | # Check if Native Compose works and has not been deleted |
| 220 | if ! $COMPOSE_COMMAND > /dev/null 2>&1; then |
| 221 | # IF it not exists/work anymore try the other command |
| 222 | COMPOSE_COMMAND="docker-compose" |
| 223 | if ! $COMPOSE_COMMAND > /dev/null 2>&1 || ! $COMPOSE_COMMAND --version | grep "^2." > /dev/null 2>&1; then |
| 224 | # IF it cannot find Standalone in > 2.X, then script stops |
| 225 | echo -e "\e[31mCannot find Docker Compose or the Version is lower then 2.X.X.\e[0m" |
| 226 | echo -e "\e[31mPlease install it regarding to this doc site: https://docs.mailcow.email/i_u_m/i_u_m_install/\e[0m" |
| 227 | exit 1 |
| 228 | fi |
| 229 | # If it finds the standalone Plugin it will use this instead and change the mailcow.conf Variable accordingly |
| 230 | echo -e "\e[31mFound different Docker Compose Version then declared in mailcow.conf!\e[0m" |
| 231 | echo -e "\e[31mSetting the DOCKER_COMPOSE_VERSION Variable from native to standalone\e[0m" |
| 232 | sed -i 's/^DOCKER_COMPOSE_VERSION=.*/DOCKER_COMPOSE_VERSION=standalone/' $SCRIPT_DIR/mailcow.conf |
| 233 | sleep 2 |
| 234 | fi |
| 235 | |
| 236 | |
| 237 | elif [ "${DOCKER_COMPOSE_VERSION}" == "standalone" ]; then |
| 238 | COMPOSE_COMMAND="docker-compose" |
| 239 | # Check if Standalone Compose works and has not been deleted |
| 240 | if ! $COMPOSE_COMMAND > /dev/null 2>&1 && ! $COMPOSE_COMMAND --version > /dev/null 2>&1 | grep "^2." > /dev/null 2>&1; then |
| 241 | # IF it not exists/work anymore try the other command |
| 242 | COMPOSE_COMMAND="docker compose" |
| 243 | if ! $COMPOSE_COMMAND > /dev/null 2>&1; then |
| 244 | # IF it cannot find Native in > 2.X, then script stops |
| 245 | echo -e "\e[31mCannot find Docker Compose.\e[0m" |
| 246 | echo -e "\e[31mPlease install it regarding to this doc site: https://docs.mailcow.email/i_u_m/i_u_m_install/\e[0m" |
| 247 | exit 1 |
| 248 | fi |
| 249 | # If it finds the native Plugin it will use this instead and change the mailcow.conf Variable accordingly |
| 250 | echo -e "\e[31mFound different Docker Compose Version then declared in mailcow.conf!\e[0m" |
| 251 | echo -e "\e[31mSetting the DOCKER_COMPOSE_VERSION Variable from standalone to native\e[0m" |
| 252 | sed -i 's/^DOCKER_COMPOSE_VERSION=.*/DOCKER_COMPOSE_VERSION=native/' $SCRIPT_DIR/mailcow.conf |
| 253 | sleep 2 |
| 254 | fi |
| 255 | fi |
| 256 | } |
| 257 | |
| 258 | detect_bad_asn() { |
| 259 | echo -e "\e[33mDetecting if your IP is listed on Spamhaus Bad ASN List...\e[0m" |
| 260 | response=$(curl --connect-timeout 15 --max-time 30 -s -o /dev/null -w "%{http_code}" "https://asn-check.mailcow.email") |
| 261 | if [ "$response" -eq 503 ]; then |
| 262 | if [ -z "$SPAMHAUS_DQS_KEY" ]; then |
| 263 | echo -e "\e[33mYour server's public IP uses an AS that is blocked by Spamhaus to use their DNS public blocklists for Postfix.\e[0m" |
| 264 | echo -e "\e[33mmailcow did not detected a value for the variable SPAMHAUS_DQS_KEY inside mailcow.conf!\e[0m" |
| 265 | sleep 2 |
| 266 | echo "" |
| 267 | echo -e "\e[33mTo use the Spamhaus DNS Blocklists again, you will need to create a FREE account for their Data Query Service (DQS) at: https://www.spamhaus.com/free-trial/sign-up-for-a-free-data-query-service-account\e[0m" |
| 268 | echo -e "\e[33mOnce done, enter your DQS API key in mailcow.conf and mailcow will do the rest for you!\e[0m" |
| 269 | echo "" |
| 270 | sleep 2 |
| 271 | |
| 272 | else |
| 273 | echo -e "\e[33mYour server's public IP uses an AS that is blocked by Spamhaus to use their DNS public blocklists for Postfix.\e[0m" |
| 274 | echo -e "\e[32mmailcow detected a Value for the variable SPAMHAUS_DQS_KEY inside mailcow.conf. Postfix will use DQS with the given API key...\e[0m" |
| 275 | fi |
| 276 | elif [ "$response" -eq 200 ]; then |
| 277 | echo -e "\e[33mCheck completed! Your IP is \e[32mclean\e[0m" |
| 278 | elif [ "$response" -eq 429 ]; then |
| 279 | echo -e "\e[33mCheck completed! \e[31mYour IP seems to be rate limited on the ASN Check service... please try again later!\e[0m" |
| 280 | else |
| 281 | echo -e "\e[31mCheck failed! \e[0mMaybe a DNS or Network problem?\e[0m" |
| 282 | fi |
| 283 | } |
| 284 | |
| 285 | ############## End Function Section ############## |
| 286 | |
| 287 | # Check permissions |
| 288 | if [ "$(id -u)" -ne "0" ]; then |
| 289 | echo "You need to be root" |
| 290 | exit 1 |
| 291 | fi |
| 292 | |
| 293 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 294 | |
| 295 | # Run pre-update-hook |
| 296 | if [ -f "${SCRIPT_DIR}/pre_update_hook.sh" ]; then |
| 297 | bash "${SCRIPT_DIR}/pre_update_hook.sh" |
| 298 | fi |
| 299 | |
| 300 | if [[ "$(uname -r)" =~ ^4\.15\.0-60 ]]; then |
| 301 | echo "DO NOT RUN mailcow ON THIS UBUNTU KERNEL!"; |
| 302 | echo "Please update to 5.x or use another distribution." |
| 303 | exit 1 |
| 304 | fi |
| 305 | |
| 306 | if [[ "$(uname -r)" =~ ^4\.4\. ]]; then |
| 307 | if grep -q Ubuntu <<< $(uname -a); then |
| 308 | echo "DO NOT RUN mailcow ON THIS UBUNTU KERNEL!" |
| 309 | echo "Please update to linux-generic-hwe-16.04 by running \"apt-get install --install-recommends linux-generic-hwe-16.04\"" |
| 310 | exit 1 |
| 311 | fi |
| 312 | echo "mailcow on a 4.4.x kernel is not supported. It may or may not work, please upgrade your kernel or continue at your own risk." |
| 313 | read -p "Press any key to continue..." < /dev/tty |
| 314 | fi |
| 315 | |
| 316 | # Exit on error and pipefail |
| 317 | set -o pipefail |
| 318 | |
| 319 | # Setting high dc timeout |
| 320 | export COMPOSE_HTTP_TIMEOUT=600 |
| 321 | |
| 322 | # Add /opt/bin to PATH |
| 323 | PATH=$PATH:/opt/bin |
| 324 | |
| 325 | umask 0022 |
| 326 | |
| 327 | # Unset COMPOSE_COMMAND and DOCKER_COMPOSE_VERSION Variable to be on the newest state. |
| 328 | unset COMPOSE_COMMAND |
| 329 | unset DOCKER_COMPOSE_VERSION |
| 330 | |
| 331 | for bin in curl docker git awk sha1sum grep cut; do |
| 332 | if [[ -z $(command -v ${bin}) ]]; then |
| 333 | echo "Cannot find ${bin}, exiting..." |
| 334 | exit 1; |
| 335 | fi |
| 336 | done |
| 337 | |
| 338 | export LC_ALL=C |
| 339 | DATE=$(date +%Y-%m-%d_%H_%M_%S) |
| 340 | BRANCH=$(cd ${SCRIPT_DIR}; git rev-parse --abbrev-ref HEAD) |
| 341 | |
| 342 | if [[ "$(cat $override | sed '/^\s*$/d' | wc -l)" == "2" ]]; then |
| 343 | mv $override ${override}_empty |
| 344 | echo -e "\e[31m${override} is empty. Renamed it to ensure mailcow is startable.\e[0m" |
| 345 | fi |
| 346 | fi |
| 347 | fi |
| 348 | fi |
| 349 | fi |
| 350 | done |
| 351 | } |
| 352 | |
| 353 | detect_docker_compose_command(){ |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 354 | if ! [ "${DOCKER_COMPOSE_VERSION}" == "native" ] && ! [ "${DOCKER_COMPOSE_VERSION}" == "standalone" ]; then |
| 355 | if docker compose > /dev/null 2>&1; then |
| 356 | if docker compose version --short | grep "2." > /dev/null 2>&1; then |
| 357 | DOCKER_COMPOSE_VERSION=native |
| 358 | COMPOSE_COMMAND="docker compose" |
| 359 | echo -e "\e[31mFound Docker Compose Plugin (native).\e[0m" |
| 360 | echo -e "\e[31mSetting the DOCKER_COMPOSE_VERSION Variable to native\e[0m" |
| 361 | sleep 2 |
| 362 | echo -e "\e[33mNotice: You'll have to update this Compose Version via your Package Manager manually!\e[0m" |
| 363 | else |
| 364 | echo -e "\e[31mCannot find Docker Compose with a Version Higher than 2.X.X.\e[0m" |
| 365 | echo -e "\e[31mPlease update/install it manually regarding to this doc site: https://mailcow.github.io/mailcow-dockerized-docs/i_u_m/i_u_m_install/\e[0m" |
| 366 | exit 1 |
| 367 | fi |
| 368 | elif docker-compose > /dev/null 2>&1; then |
| 369 | if ! [[ $(alias docker-compose 2> /dev/null) ]] ; then |
| 370 | if docker-compose version --short | grep "^2." > /dev/null 2>&1; then |
| 371 | DOCKER_COMPOSE_VERSION=standalone |
| 372 | COMPOSE_COMMAND="docker-compose" |
| 373 | echo -e "\e[31mFound Docker Compose Standalone.\e[0m" |
| 374 | echo -e "\e[31mSetting the DOCKER_COMPOSE_VERSION Variable to standalone\e[0m" |
| 375 | sleep 2 |
| 376 | echo -e "\e[33mNotice: For an automatic update of docker-compose please use the update_compose.sh scripts located at the helper-scripts folder.\e[0m" |
| 377 | else |
| 378 | echo -e "\e[31mCannot find Docker Compose with a Version Higher than 2.X.X.\e[0m" |
| 379 | echo -e "\e[31mPlease update/install regarding to this doc site: https://mailcow.github.io/mailcow-dockerized-docs/i_u_m/i_u_m_install/\e[0m" |
| 380 | exit 1 |
| 381 | fi |
| 382 | fi |
| 383 | |
| 384 | else |
| 385 | echo -e "\e[31mCannot find Docker Compose.\e[0m" |
| 386 | echo -e "\e[31mPlease install it regarding to this doc site: https://mailcow.github.io/mailcow-dockerized-docs/i_u_m/i_u_m_install/\e[0m" |
| 387 | exit 1 |
| 388 | fi |
| 389 | |
| 390 | elif [ "${DOCKER_COMPOSE_VERSION}" == "native" ]; then |
| 391 | COMPOSE_COMMAND="docker compose" |
| 392 | |
| 393 | elif [ "${DOCKER_COMPOSE_VERSION}" == "standalone" ]; then |
| 394 | COMPOSE_COMMAND="docker-compose" |
| 395 | fi |
| 396 | } |
| 397 | |
| 398 | ############## End Function Section ############## |
| 399 | |
| 400 | # Check permissions |
| 401 | if [ "$(id -u)" -ne "0" ]; then |
| 402 | echo "You need to be root" |
| 403 | exit 1 |
| 404 | fi |
| 405 | |
| 406 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 407 | |
| 408 | # Run pre-update-hook |
| 409 | if [ -f "${SCRIPT_DIR}/pre_update_hook.sh" ]; then |
| 410 | bash "${SCRIPT_DIR}/pre_update_hook.sh" |
| 411 | fi |
| 412 | |
| 413 | if [[ "$(uname -r)" =~ ^4\.15\.0-60 ]]; then |
| 414 | echo "DO NOT RUN mailcow ON THIS UBUNTU KERNEL!"; |
| 415 | echo "Please update to 5.x or use another distribution." |
| 416 | exit 1 |
| 417 | fi |
| 418 | |
| 419 | if [[ "$(uname -r)" =~ ^4\.4\. ]]; then |
| 420 | if grep -q Ubuntu <<< $(uname -a); then |
| 421 | echo "DO NOT RUN mailcow ON THIS UBUNTU KERNEL!" |
| 422 | echo "Please update to linux-generic-hwe-16.04 by running \"apt-get install --install-recommends linux-generic-hwe-16.04\"" |
| 423 | exit 1 |
| 424 | fi |
| 425 | echo "mailcow on a 4.4.x kernel is not supported. It may or may not work, please upgrade your kernel or continue at your own risk." |
| 426 | read -p "Press any key to continue..." < /dev/tty |
| 427 | fi |
| 428 | |
| 429 | # Exit on error and pipefail |
| 430 | set -o pipefail |
| 431 | |
| 432 | # Setting high dc timeout |
| 433 | export COMPOSE_HTTP_TIMEOUT=600 |
| 434 | |
| 435 | # Add /opt/bin to PATH |
| 436 | PATH=$PATH:/opt/bin |
| 437 | |
| 438 | umask 0022 |
| 439 | |
| 440 | # Unset COMPOSE_COMMAND and DOCKER_COMPOSE_VERSION Variable to be on the newest state. |
| 441 | unset COMPOSE_COMMAND |
| 442 | unset DOCKER_COMPOSE_VERSION |
| 443 | |
| 444 | for bin in curl docker git awk sha1sum; do |
| 445 | if [[ -z $(command -v ${bin}) ]]; then |
| 446 | echo "Cannot find ${bin}, exiting..." |
| 447 | exit 1; |
| 448 | fi |
| 449 | done |
| 450 | |
| 451 | export LC_ALL=C |
| 452 | DATE=$(date +%Y-%m-%d_%H_%M_%S) |
| 453 | BRANCH=$(cd ${SCRIPT_DIR}; git rev-parse --abbrev-ref HEAD) |
| 454 | |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 455 | while (($#)); do |
| 456 | case "${1}" in |
| 457 | --check|-c) |
| 458 | echo "Checking remote code for updates..." |
| 459 | LATEST_REV=$(git ls-remote --exit-code --refs --quiet https://github.com/mailcow/mailcow-dockerized ${BRANCH} | cut -f1) |
| 460 | if [ $? -ne 0 ]; then |
| 461 | echo "A problem occurred while trying to fetch the latest revision from github." |
| 462 | exit 99 |
| 463 | fi |
| 464 | if [[ -z $(git log HEAD --pretty=format:"%H" | grep "${LATEST_REV}") ]]; then |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 465 | echo -e "Updated code is available.\nThe changes can be found here: https://github.com/mailcow/mailcow-dockerized/commits/master" |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 466 | git log --date=short --pretty=format:"%ad - %s" $(git rev-parse --short HEAD)..origin/master |
| 467 | exit 0 |
| 468 | else |
| 469 | echo "No updates available." |
| 470 | exit 3 |
| 471 | fi |
| 472 | ;; |
| 473 | --ours) |
| 474 | MERGE_STRATEGY=ours |
| 475 | ;; |
| 476 | --skip-start) |
| 477 | SKIP_START=y |
| 478 | ;; |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 479 | --skip-ping-check) |
| 480 | SKIP_PING_CHECK=y |
| 481 | ;; |
| 482 | --stable) |
| 483 | CURRENT_BRANCH="$(cd ${SCRIPT_DIR}; git rev-parse --abbrev-ref HEAD)" |
| 484 | NEW_BRANCH="master" |
| 485 | ;; |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 486 | --gc) |
| 487 | echo -e "\e[32mCollecting garbage...\e[0m" |
| 488 | docker_garbage |
| 489 | exit 0 |
| 490 | ;; |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 491 | --nightly) |
| 492 | CURRENT_BRANCH="$(cd ${SCRIPT_DIR}; git rev-parse --abbrev-ref HEAD)" |
| 493 | NEW_BRANCH="nightly" |
| 494 | ;; |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 495 | --prefetch) |
| 496 | echo -e "\e[32mPrefetching images...\e[0m" |
| 497 | prefetch_images |
| 498 | exit 0 |
| 499 | ;; |
| 500 | -f|--force) |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 501 | echo -e "\e[32mRunning in forced mode...\e[0m" |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 502 | FORCE=y |
| 503 | ;; |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame^] | 504 | -d|--dev) |
| 505 | echo -e "\e[32mRunning in Developer mode...\e[0m" |
| 506 | DEV=y |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 507 | --help|-h) |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame^] | 508 | echo './update.sh [-c|--check, --ours, --gc, --nightly, --prefetch, --skip-start, --skip-ping-check, --stable, -f|--force, -d|--dev, -h|--help] |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 509 | |
| 510 | -c|--check - Check for updates and exit (exit codes => 0: update available, 3: no updates) |
| 511 | --ours - Use merge strategy option "ours" to solve conflicts in favor of non-mailcow code (local changes over remote changes), not recommended! |
| 512 | --gc - Run garbage collector to delete old image tags |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 513 | --nightly - Switch your mailcow updates to the unstable (nightly) branch. FOR TESTING PURPOSES ONLY!!!! |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 514 | --prefetch - Only prefetch new images and exit (useful to prepare updates) |
| 515 | --skip-start - Do not start mailcow after update |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 516 | --skip-ping-check - Skip ICMP Check to public DNS resolvers (Use it only if you´ve blocked any ICMP Connections to your mailcow machine) |
| 517 | --stable - Switch your mailcow updates to the stable (master) branch. Default unless you changed it with --nightly. |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 518 | -f|--force - Force update, do not ask questions |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame^] | 519 | -d|--dev - Enables Developer Mode (No Checkout of update.sh for tests) |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 520 | ' |
| 521 | exit 1 |
| 522 | esac |
| 523 | shift |
| 524 | done |
| 525 | |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 526 | chmod 600 mailcow.conf |
| 527 | source mailcow.conf |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 528 | |
| 529 | detect_docker_compose_command |
| 530 | |
| 531 | [[ ! -f mailcow.conf ]] && { echo "mailcow.conf is missing! Is mailcow installed?"; exit 1;} |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 532 | DOTS=${MAILCOW_HOSTNAME//[^.]}; |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame^] | 533 | if [ ${#DOTS} -lt 1 ]; then |
| 534 | echo -e "\e[31mMAILCOW_HOSTNAME (${MAILCOW_HOSTNAME}) is not a FQDN!\e[0m" |
| 535 | sleep 1 |
| 536 | echo "Please change it to a FQDN and redeploy the stack with $COMPOSE_COMMAND up -d" |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 537 | exit 1 |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame^] | 538 | elif [[ "${MAILCOW_HOSTNAME: -1}" == "." ]]; then |
| 539 | echo "MAILCOW_HOSTNAME (${MAILCOW_HOSTNAME}) is ending with a dot. This is not a valid FQDN!" |
| 540 | exit 1 |
| 541 | elif [ ${#DOTS} -eq 1 ]; then |
| 542 | echo -e "\e[33mMAILCOW_HOSTNAME (${MAILCOW_HOSTNAME}) does not contain a Subdomain. This is not fully tested and may cause issues.\e[0m" |
| 543 | echo "Find more information about why this message exists here: https://github.com/mailcow/mailcow-dockerized/issues/1572" |
| 544 | read -r -p "Do you want to proceed anyway? [y/N] " response |
| 545 | if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then |
| 546 | echo "OK. Procceding." |
| 547 | else |
| 548 | echo "OK. Exiting." |
| 549 | exit 1 |
| 550 | fi |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 551 | fi |
| 552 | |
| 553 | if grep --help 2>&1 | head -n 1 | grep -q -i "busybox"; then echo "BusyBox grep detected, please install gnu grep, \"apk add --no-cache --upgrade grep\""; exit 1; fi |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 554 | # This will also cover sort |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 555 | if cp --help 2>&1 | head -n 1 | grep -q -i "busybox"; then echo "BusyBox cp detected, please install coreutils, \"apk add --no-cache --upgrade coreutils\""; exit 1; fi |
| 556 | if sed --help 2>&1 | head -n 1 | grep -q -i "busybox"; then echo "BusyBox sed detected, please install gnu sed, \"apk add --no-cache --upgrade sed\""; exit 1; fi |
| 557 | |
| 558 | CONFIG_ARRAY=( |
| 559 | "SKIP_LETS_ENCRYPT" |
| 560 | "SKIP_SOGO" |
| 561 | "USE_WATCHDOG" |
| 562 | "WATCHDOG_NOTIFY_EMAIL" |
| 563 | "WATCHDOG_NOTIFY_BAN" |
| 564 | "WATCHDOG_EXTERNAL_CHECKS" |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 565 | "WATCHDOG_SUBJECT" |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 566 | "SKIP_CLAMD" |
| 567 | "SKIP_IP_CHECK" |
| 568 | "ADDITIONAL_SAN" |
| 569 | "DOVEADM_PORT" |
| 570 | "IPV4_NETWORK" |
| 571 | "IPV6_NETWORK" |
| 572 | "LOG_LINES" |
| 573 | "SNAT_TO_SOURCE" |
| 574 | "SNAT6_TO_SOURCE" |
| 575 | "COMPOSE_PROJECT_NAME" |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 576 | "DOCKER_COMPOSE_VERSION" |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 577 | "SQL_PORT" |
| 578 | "API_KEY" |
| 579 | "API_KEY_READ_ONLY" |
| 580 | "API_ALLOW_FROM" |
| 581 | "MAILDIR_GC_TIME" |
| 582 | "MAILDIR_SUB" |
| 583 | "ACL_ANYONE" |
| 584 | "SOLR_HEAP" |
| 585 | "SKIP_SOLR" |
| 586 | "ENABLE_SSL_SNI" |
| 587 | "ALLOW_ADMIN_EMAIL_LOGIN" |
| 588 | "SKIP_HTTP_VERIFICATION" |
| 589 | "SOGO_EXPIRE_SESSION" |
| 590 | "REDIS_PORT" |
| 591 | "DOVECOT_MASTER_USER" |
| 592 | "DOVECOT_MASTER_PASS" |
| 593 | "MAILCOW_PASS_SCHEME" |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 594 | "ADDITIONAL_SERVER_NAMES" |
| 595 | "ACME_CONTACT" |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 596 | "WATCHDOG_VERBOSE" |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 597 | "WEBAUTHN_ONLY_TRUSTED_VENDORS" |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame^] | 598 | "SPAMHAUS_DQS_KEY" |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 599 | ) |
| 600 | |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame^] | 601 | detect_bad_asn |
| 602 | |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 603 | sed -i --follow-symlinks '$a\' mailcow.conf |
| 604 | for option in ${CONFIG_ARRAY[@]}; do |
| 605 | if [[ ${option} == "ADDITIONAL_SAN" ]]; then |
| 606 | if ! grep -q ${option} mailcow.conf; then |
| 607 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 608 | echo "${option}=" >> mailcow.conf |
| 609 | fi |
| 610 | elif [[ ${option} == "COMPOSE_PROJECT_NAME" ]]; then |
| 611 | if ! grep -q ${option} mailcow.conf; then |
| 612 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 613 | echo "COMPOSE_PROJECT_NAME=mailcowdockerized" >> mailcow.conf |
| 614 | fi |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 615 | elif [[ ${option} == "DOCKER_COMPOSE_VERSION" ]]; then |
| 616 | if ! grep -q ${option} mailcow.conf; then |
| 617 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 618 | echo "# Used Docker Compose version" >> mailcow.conf |
| 619 | echo "# Switch here between native (compose plugin) and standalone" >> mailcow.conf |
| 620 | echo "# For more informations take a look at the mailcow docs regarding the configuration options." >> mailcow.conf |
| 621 | echo "# Normally this should be untouched but if you decided to use either of those you can switch it manually here." >> mailcow.conf |
| 622 | echo "# Please be aware that at least one of those variants should be installed on your maschine or mailcow will fail." >> mailcow.conf |
| 623 | echo "" >> mailcow.conf |
| 624 | echo "DOCKER_COMPOSE_VERSION=${DOCKER_COMPOSE_VERSION}" >> mailcow.conf |
| 625 | fi |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 626 | elif [[ ${option} == "DOVEADM_PORT" ]]; then |
| 627 | if ! grep -q ${option} mailcow.conf; then |
| 628 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 629 | echo "DOVEADM_PORT=127.0.0.1:19991" >> mailcow.conf |
| 630 | fi |
| 631 | elif [[ ${option} == "WATCHDOG_NOTIFY_EMAIL" ]]; then |
| 632 | if ! grep -q ${option} mailcow.conf; then |
| 633 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 634 | echo "WATCHDOG_NOTIFY_EMAIL=" >> mailcow.conf |
| 635 | fi |
| 636 | elif [[ ${option} == "LOG_LINES" ]]; then |
| 637 | if ! grep -q ${option} mailcow.conf; then |
| 638 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 639 | echo '# Max log lines per service to keep in Redis logs' >> mailcow.conf |
| 640 | echo "LOG_LINES=9999" >> mailcow.conf |
| 641 | fi |
| 642 | elif [[ ${option} == "IPV4_NETWORK" ]]; then |
| 643 | if ! grep -q ${option} mailcow.conf; then |
| 644 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 645 | echo '# Internal IPv4 /24 subnet, format n.n.n. (expands to n.n.n.0/24)' >> mailcow.conf |
| 646 | echo "IPV4_NETWORK=172.22.1" >> mailcow.conf |
| 647 | fi |
| 648 | elif [[ ${option} == "IPV6_NETWORK" ]]; then |
| 649 | if ! grep -q ${option} mailcow.conf; then |
| 650 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 651 | echo '# Internal IPv6 subnet in fc00::/7' >> mailcow.conf |
| 652 | echo "IPV6_NETWORK=fd4d:6169:6c63:6f77::/64" >> mailcow.conf |
| 653 | fi |
| 654 | elif [[ ${option} == "SQL_PORT" ]]; then |
| 655 | if ! grep -q ${option} mailcow.conf; then |
| 656 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 657 | echo '# Bind SQL to 127.0.0.1 on port 13306' >> mailcow.conf |
| 658 | echo "SQL_PORT=127.0.0.1:13306" >> mailcow.conf |
| 659 | fi |
| 660 | elif [[ ${option} == "API_KEY" ]]; then |
| 661 | if ! grep -q ${option} mailcow.conf; then |
| 662 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 663 | echo '# Create or override API key for web UI' >> mailcow.conf |
| 664 | echo "#API_KEY=" >> mailcow.conf |
| 665 | fi |
| 666 | elif [[ ${option} == "API_KEY_READ_ONLY" ]]; then |
| 667 | if ! grep -q ${option} mailcow.conf; then |
| 668 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 669 | echo '# Create or override read-only API key for web UI' >> mailcow.conf |
| 670 | echo "#API_KEY_READ_ONLY=" >> mailcow.conf |
| 671 | fi |
| 672 | elif [[ ${option} == "API_ALLOW_FROM" ]]; then |
| 673 | if ! grep -q ${option} mailcow.conf; then |
| 674 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 675 | echo '# Must be set for API_KEY to be active' >> mailcow.conf |
| 676 | echo '# IPs only, no networks (networks can be set via UI)' >> mailcow.conf |
| 677 | echo "#API_ALLOW_FROM=" >> mailcow.conf |
| 678 | fi |
| 679 | elif [[ ${option} == "SNAT_TO_SOURCE" ]]; then |
| 680 | if ! grep -q ${option} mailcow.conf; then |
| 681 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 682 | echo '# Use this IPv4 for outgoing connections (SNAT)' >> mailcow.conf |
| 683 | echo "#SNAT_TO_SOURCE=" >> mailcow.conf |
| 684 | fi |
| 685 | elif [[ ${option} == "SNAT6_TO_SOURCE" ]]; then |
| 686 | if ! grep -q ${option} mailcow.conf; then |
| 687 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 688 | echo '# Use this IPv6 for outgoing connections (SNAT)' >> mailcow.conf |
| 689 | echo "#SNAT6_TO_SOURCE=" >> mailcow.conf |
| 690 | fi |
| 691 | elif [[ ${option} == "MAILDIR_GC_TIME" ]]; then |
| 692 | if ! grep -q ${option} mailcow.conf; then |
| 693 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 694 | echo '# Garbage collector cleanup' >> mailcow.conf |
| 695 | echo '# Deleted domains and mailboxes are moved to /var/vmail/_garbage/timestamp_sanitizedstring' >> mailcow.conf |
| 696 | echo '# How long should objects remain in the garbage until they are being deleted? (value in minutes)' >> mailcow.conf |
| 697 | echo '# Check interval is hourly' >> mailcow.conf |
| 698 | echo 'MAILDIR_GC_TIME=1440' >> mailcow.conf |
| 699 | fi |
| 700 | elif [[ ${option} == "ACL_ANYONE" ]]; then |
| 701 | if ! grep -q ${option} mailcow.conf; then |
| 702 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 703 | echo '# Set this to "allow" to enable the anyone pseudo user. Disabled by default.' >> mailcow.conf |
| 704 | echo '# When enabled, ACL can be created, that apply to "All authenticated users"' >> mailcow.conf |
| 705 | echo '# This should probably only be activated on mail hosts, that are used exclusivly by one organisation.' >> mailcow.conf |
| 706 | echo '# Otherwise a user might share data with too many other users.' >> mailcow.conf |
| 707 | echo 'ACL_ANYONE=disallow' >> mailcow.conf |
| 708 | fi |
| 709 | elif [[ ${option} == "SOLR_HEAP" ]]; then |
| 710 | if ! grep -q ${option} mailcow.conf; then |
| 711 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 712 | echo '# Solr heap size, there is no recommendation, please see Solr docs.' >> mailcow.conf |
| 713 | echo '# Solr is a prone to run OOM on large systems and should be monitored. Unmonitored Solr setups are not recommended.' >> mailcow.conf |
| 714 | echo '# Solr will refuse to start with total system memory below or equal to 2 GB.' >> mailcow.conf |
| 715 | echo "SOLR_HEAP=1024" >> mailcow.conf |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 716 | fi |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 717 | elif [[ ${option} == "SKIP_SOLR" ]]; then |
| 718 | if ! grep -q ${option} mailcow.conf; then |
| 719 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 720 | echo '# Solr is disabled by default after upgrading from non-Solr to Solr-enabled mailcows.' >> mailcow.conf |
| 721 | echo '# Disable Solr or if you do not want to store a readable index of your mails in solr-vol-1.' >> mailcow.conf |
| 722 | echo "SKIP_SOLR=y" >> mailcow.conf |
| 723 | fi |
| 724 | elif [[ ${option} == "ENABLE_SSL_SNI" ]]; then |
| 725 | if ! grep -q ${option} mailcow.conf; then |
| 726 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 727 | echo '# Create seperate certificates for all domains - y/n' >> mailcow.conf |
| 728 | echo '# this will allow adding more than 100 domains, but some email clients will not be able to connect with alternative hostnames' >> mailcow.conf |
| 729 | echo '# see https://wiki.dovecot.org/SSL/SNIClientSupport' >> mailcow.conf |
| 730 | echo "ENABLE_SSL_SNI=n" >> mailcow.conf |
| 731 | fi |
| 732 | elif [[ ${option} == "SKIP_SOGO" ]]; then |
| 733 | if ! grep -q ${option} mailcow.conf; then |
| 734 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 735 | echo '# Skip SOGo: Will disable SOGo integration and therefore webmail, DAV protocols and ActiveSync support (experimental, unsupported, not fully implemented) - y/n' >> mailcow.conf |
| 736 | echo "SKIP_SOGO=n" >> mailcow.conf |
| 737 | fi |
| 738 | elif [[ ${option} == "MAILDIR_SUB" ]]; then |
| 739 | if ! grep -q ${option} mailcow.conf; then |
| 740 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 741 | echo '# MAILDIR_SUB defines a path in a users virtual home to keep the maildir in. Leave empty for updated setups.' >> mailcow.conf |
| 742 | echo "#MAILDIR_SUB=Maildir" >> mailcow.conf |
| 743 | echo "MAILDIR_SUB=" >> mailcow.conf |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 744 | fi |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 745 | elif [[ ${option} == "WATCHDOG_NOTIFY_BAN" ]]; then |
| 746 | if ! grep -q ${option} mailcow.conf; then |
| 747 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 748 | echo '# Notify about banned IP. Includes whois lookup.' >> mailcow.conf |
| 749 | echo "WATCHDOG_NOTIFY_BAN=y" >> mailcow.conf |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 750 | fi |
| 751 | elif [[ ${option} == "WATCHDOG_SUBJECT" ]]; then |
| 752 | if ! grep -q ${option} mailcow.conf; then |
| 753 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 754 | echo '# Subject for watchdog mails. Defaults to "Watchdog ALERT" followed by the error message.' >> mailcow.conf |
| 755 | echo "#WATCHDOG_SUBJECT=" >> mailcow.conf |
| 756 | fi |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 757 | elif [[ ${option} == "WATCHDOG_EXTERNAL_CHECKS" ]]; then |
| 758 | if ! grep -q ${option} mailcow.conf; then |
| 759 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 760 | echo '# Checks if mailcow is an open relay. Requires a SAL. More checks will follow.' >> mailcow.conf |
| 761 | echo '# No data is collected. Opt-in and anonymous.' >> mailcow.conf |
| 762 | echo '# Will only work with unmodified mailcow setups.' >> mailcow.conf |
| 763 | echo "WATCHDOG_EXTERNAL_CHECKS=n" >> mailcow.conf |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 764 | fi |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 765 | elif [[ ${option} == "SOGO_EXPIRE_SESSION" ]]; then |
| 766 | if ! grep -q ${option} mailcow.conf; then |
| 767 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 768 | echo '# SOGo session timeout in minutes' >> mailcow.conf |
| 769 | echo "SOGO_EXPIRE_SESSION=480" >> mailcow.conf |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 770 | fi |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 771 | elif [[ ${option} == "REDIS_PORT" ]]; then |
| 772 | if ! grep -q ${option} mailcow.conf; then |
| 773 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 774 | echo "REDIS_PORT=127.0.0.1:7654" >> mailcow.conf |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 775 | fi |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 776 | elif [[ ${option} == "DOVECOT_MASTER_USER" ]]; then |
| 777 | if ! grep -q ${option} mailcow.conf; then |
| 778 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 779 | echo '# DOVECOT_MASTER_USER and _PASS must _both_ be provided. No special chars.' >> mailcow.conf |
| 780 | echo '# Empty by default to auto-generate master user and password on start.' >> mailcow.conf |
| 781 | echo '# User expands to DOVECOT_MASTER_USER@mailcow.local' >> mailcow.conf |
| 782 | echo '# LEAVE EMPTY IF UNSURE' >> mailcow.conf |
| 783 | echo "DOVECOT_MASTER_USER=" >> mailcow.conf |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 784 | fi |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 785 | elif [[ ${option} == "DOVECOT_MASTER_PASS" ]]; then |
| 786 | if ! grep -q ${option} mailcow.conf; then |
| 787 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 788 | echo '# LEAVE EMPTY IF UNSURE' >> mailcow.conf |
| 789 | echo "DOVECOT_MASTER_PASS=" >> mailcow.conf |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 790 | fi |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 791 | elif [[ ${option} == "MAILCOW_PASS_SCHEME" ]]; then |
| 792 | if ! grep -q ${option} mailcow.conf; then |
| 793 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 794 | echo '# Password hash algorithm' >> mailcow.conf |
| 795 | echo '# Only certain password hash algorithm are supported. For a fully list of supported schemes,' >> mailcow.conf |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame^] | 796 | echo '# see https://docs.mailcow.email/models/model-passwd/' >> mailcow.conf |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 797 | echo "MAILCOW_PASS_SCHEME=BLF-CRYPT" >> mailcow.conf |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 798 | fi |
| 799 | elif [[ ${option} == "ADDITIONAL_SERVER_NAMES" ]]; then |
| 800 | if ! grep -q ${option} mailcow.conf; then |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame^] | 801 | echo "Adding new option \"${option}\" to mailcow.conf" |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 802 | echo '# Additional server names for mailcow UI' >> mailcow.conf |
| 803 | echo '#' >> mailcow.conf |
| 804 | echo '# Specify alternative addresses for the mailcow UI to respond to' >> mailcow.conf |
| 805 | echo '# This is useful when you set mail.* as ADDITIONAL_SAN and want to make sure mail.maildomain.com will always point to the mailcow UI.' >> mailcow.conf |
| 806 | echo '# If the server name does not match a known site, Nginx decides by best-guess and may redirect users to the wrong web root.' >> mailcow.conf |
| 807 | echo '# You can understand this as server_name directive in Nginx.' >> mailcow.conf |
| 808 | echo '# Comma separated list without spaces! Example: ADDITIONAL_SERVER_NAMES=a.b.c,d.e.f' >> mailcow.conf |
| 809 | echo 'ADDITIONAL_SERVER_NAMES=' >> mailcow.conf |
| 810 | fi |
| 811 | elif [[ ${option} == "ACME_CONTACT" ]]; then |
| 812 | if ! grep -q ${option} mailcow.conf; then |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame^] | 813 | echo "Adding new option \"${option}\" to mailcow.conf" |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 814 | echo '# Lets Encrypt registration contact information' >> mailcow.conf |
| 815 | echo '# Optional: Leave empty for none' >> mailcow.conf |
| 816 | echo '# This value is only used on first order!' >> mailcow.conf |
| 817 | echo '# Setting it at a later point will require the following steps:' >> mailcow.conf |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame^] | 818 | echo '# https://docs.mailcow.email/troubleshooting/debug-reset_tls/' >> mailcow.conf |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 819 | echo 'ACME_CONTACT=' >> mailcow.conf |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame^] | 820 | fi |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 821 | elif [[ ${option} == "WEBAUTHN_ONLY_TRUSTED_VENDORS" ]]; then |
| 822 | if ! grep -q ${option} mailcow.conf; then |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame^] | 823 | echo "Adding new option \"${option}\" to mailcow.conf" |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 824 | echo "# WebAuthn device manufacturer verification" >> mailcow.conf |
| 825 | echo '# After setting WEBAUTHN_ONLY_TRUSTED_VENDORS=y only devices from trusted manufacturers are allowed' >> mailcow.conf |
| 826 | echo '# root certificates can be placed for validation under mailcow-dockerized/data/web/inc/lib/WebAuthn/rootCertificates' >> mailcow.conf |
| 827 | echo 'WEBAUTHN_ONLY_TRUSTED_VENDORS=n' >> mailcow.conf |
| 828 | fi |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame^] | 829 | elif [[ ${option} == "SPAMHAUS_DQS_KEY" ]]; then |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 830 | if ! grep -q ${option} mailcow.conf; then |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame^] | 831 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 832 | echo "# Spamhaus Data Query Service Key" >> mailcow.conf |
| 833 | echo '# Optional: Leave empty for none' >> mailcow.conf |
| 834 | echo '# Enter your key here if you are using a blocked ASN (OVH, AWS, Cloudflare e.g) for the unregistered Spamhaus Blocklist.' >> mailcow.conf |
| 835 | echo '# If empty, it will completely disable Spamhaus blocklists if it detects that you are running on a server using a blocked AS.' >> mailcow.conf |
| 836 | echo '# Otherwise it will work as usual.' >> mailcow.conf |
| 837 | echo 'SPAMHAUS_DQS_KEY=' >> mailcow.conf |
| 838 | fi |
| 839 | elif [[ ${option} == "WATCHDOG_VERBOSE" ]]; then |
| 840 | if ! grep -q ${option} mailcow.conf; then |
| 841 | echo "Adding new option \"${option}\" to mailcow.conf" |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 842 | echo '# Enable watchdog verbose logging' >> mailcow.conf |
| 843 | echo 'WATCHDOG_VERBOSE=n' >> mailcow.conf |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame^] | 844 | fi |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 845 | elif ! grep -q ${option} mailcow.conf; then |
| 846 | echo "Adding new option \"${option}\" to mailcow.conf" |
| 847 | echo "${option}=n" >> mailcow.conf |
| 848 | fi |
| 849 | done |
| 850 | |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 851 | if [[( ${SKIP_PING_CHECK} == "y")]]; then |
| 852 | echo -e "\e[32mSkipping Ping Check...\e[0m" |
| 853 | |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 854 | else |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 855 | echo -en "Checking internet connection... " |
| 856 | if ! check_online_status; then |
| 857 | echo -e "\e[31mfailed\e[0m" |
| 858 | exit 1 |
| 859 | else |
| 860 | echo -e "\e[32mOK\e[0m" |
| 861 | fi |
| 862 | fi |
| 863 | |
| 864 | if ! [ $NEW_BRANCH ]; then |
| 865 | echo -e "\e[33mDetecting which build your mailcow runs on...\e[0m" |
| 866 | sleep 1 |
| 867 | if [ ${BRANCH} == "master" ]; then |
| 868 | echo -e "\e[32mYou are receiving stable updates (master).\e[0m" |
| 869 | echo -e "\e[33mTo change that run the update.sh Script one time with the --nightly parameter to switch to nightly builds.\e[0m" |
| 870 | |
| 871 | elif [ ${BRANCH} == "nightly" ]; then |
| 872 | echo -e "\e[31mYou are receiving unstable updates (nightly). These are for testing purposes only!!!\e[0m" |
| 873 | sleep 1 |
| 874 | echo -e "\e[33mTo change that run the update.sh Script one time with the --stable parameter to switch to stable builds.\e[0m" |
| 875 | |
| 876 | else |
| 877 | echo -e "\e[33mYou are receiving updates from a unsupported branch.\e[0m" |
| 878 | sleep 1 |
| 879 | echo -e "\e[33mThe mailcow stack might still work but it is recommended to switch to the master branch (stable builds).\e[0m" |
| 880 | echo -e "\e[33mTo change that run the update.sh Script one time with the --stable parameter to switch to stable builds.\e[0m" |
| 881 | fi |
| 882 | elif [ $FORCE ]; then |
| 883 | echo -e "\e[31mYou are running in forced mode!\e[0m" |
| 884 | echo -e "\e[31mA Branch Switch can only be performed manually (monitored).\e[0m" |
| 885 | echo -e "\e[31mPlease rerun the update.sh Script without the --force/-f parameter.\e[0m" |
| 886 | sleep 1 |
| 887 | elif [ $NEW_BRANCH == "master" ] && [ $CURRENT_BRANCH != "master" ]; then |
| 888 | echo -e "\e[33mYou are about to switch your mailcow Updates to the stable (master) branch.\e[0m" |
| 889 | sleep 1 |
| 890 | echo -e "\e[33mBefore you do: Please take a backup of all components to ensure that no Data is lost...\e[0m" |
| 891 | sleep 1 |
| 892 | echo -e "\e[31mWARNING: Please see on GitHub or ask in the communitys if a switch to master is stable or not. |
| 893 | In some rear cases a Update back to master can destroy your mailcow configuration in case of Database Upgrades etc. |
| 894 | Normally a upgrade back to master should be safe during each full release. |
| 895 | Check GitHub for Database Changes and Update only if there similar to the full release!\e[0m" |
| 896 | read -r -p "Are you sure you that want to continue upgrading to the stable (master) branch? [y/N] " response |
| 897 | if [[ ! "${response}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then |
| 898 | echo "OK. If you prepared yourself for that please run the update.sh Script with the --stable parameter again to trigger this process here." |
| 899 | exit 0 |
| 900 | fi |
| 901 | BRANCH=$NEW_BRANCH |
| 902 | DIFF_DIRECTORY=update_diffs |
| 903 | DIFF_FILE=${DIFF_DIRECTORY}/diff_before_upgrade_to_master_$(date +"%Y-%m-%d-%H-%M-%S") |
| 904 | mv diff_before_upgrade* ${DIFF_DIRECTORY}/ 2> /dev/null |
| 905 | if ! git diff-index --quiet HEAD; then |
| 906 | echo -e "\e[32mSaving diff to ${DIFF_FILE}...\e[0m" |
| 907 | mkdir -p ${DIFF_DIRECTORY} |
| 908 | git diff ${BRANCH} --stat > ${DIFF_FILE} |
| 909 | git diff ${BRANCH} >> ${DIFF_FILE} |
| 910 | fi |
| 911 | echo -e "\e[32mSwitching Branch to ${BRANCH}...\e[0m" |
| 912 | git fetch origin |
| 913 | git checkout -f ${BRANCH} |
| 914 | |
| 915 | elif [ $NEW_BRANCH == "nightly" ] && [ $CURRENT_BRANCH != "nightly" ]; then |
| 916 | echo -e "\e[33mYou are about to switch your mailcow Updates to the unstable (nightly) branch.\e[0m" |
| 917 | sleep 1 |
| 918 | echo -e "\e[33mBefore you do: Please take a backup of all components to ensure that no Data is lost...\e[0m" |
| 919 | sleep 1 |
| 920 | echo -e "\e[31mWARNING: A switch to nightly is possible any time. But a switch back (to master) isn't.\e[0m" |
| 921 | read -r -p "Are you sure you that want to continue upgrading to the unstable (nightly) branch? [y/N] " response |
| 922 | if [[ ! "${response}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then |
| 923 | echo "OK. If you prepared yourself for that please run the update.sh Script with the --nightly parameter again to trigger this process here." |
| 924 | exit 0 |
| 925 | fi |
| 926 | BRANCH=$NEW_BRANCH |
| 927 | DIFF_DIRECTORY=update_diffs |
| 928 | DIFF_FILE=${DIFF_DIRECTORY}/diff_before_upgrade_to_nightly_$(date +"%Y-%m-%d-%H-%M-%S") |
| 929 | mv diff_before_upgrade* ${DIFF_DIRECTORY}/ 2> /dev/null |
| 930 | if ! git diff-index --quiet HEAD; then |
| 931 | echo -e "\e[32mSaving diff to ${DIFF_FILE}...\e[0m" |
| 932 | mkdir -p ${DIFF_DIRECTORY} |
| 933 | git diff ${BRANCH} --stat > ${DIFF_FILE} |
| 934 | git diff ${BRANCH} >> ${DIFF_FILE} |
| 935 | fi |
| 936 | git fetch origin |
| 937 | git checkout -f ${BRANCH} |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 938 | fi |
| 939 | |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame^] | 940 | else |
| 941 | echo -e "\e[33mYou are receiving updates from a unsupported branch.\e[0m" |
| 942 | sleep 1 |
| 943 | echo -e "\e[33mThe mailcow stack might still work but it is recommended to switch to the master branch (stable builds).\e[0m" |
| 944 | echo -e "\e[33mTo change that run the update.sh Script one time with the --stable parameter to switch to stable builds.\e[0m" |
| 945 | fi |
| 946 | elif [ $FORCE ]; then |
| 947 | echo -e "\e[31mYou are running in forced mode!\e[0m" |
| 948 | echo -e "\e[31mA Branch Switch can only be performed manually (monitored).\e[0m" |
| 949 | echo -e "\e[31mPlease rerun the update.sh Script without the --force/-f parameter.\e[0m" |
| 950 | sleep 1 |
| 951 | elif [ $NEW_BRANCH == "master" ] && [ $CURRENT_BRANCH != "master" ]; then |
| 952 | echo -e "\e[33mYou are about to switch your mailcow Updates to the stable (master) branch.\e[0m" |
| 953 | sleep 1 |
| 954 | echo -e "\e[33mBefore you do: Please take a backup of all components to ensure that no Data is lost...\e[0m" |
| 955 | sleep 1 |
| 956 | echo -e "\e[31mWARNING: Please see on GitHub or ask in the communitys if a switch to master is stable or not. |
| 957 | In some rear cases a Update back to master can destroy your mailcow configuration in case of Database Upgrades etc. |
| 958 | Normally a upgrade back to master should be safe during each full release. |
| 959 | Check GitHub for Database Changes and Update only if there similar to the full release!\e[0m" |
| 960 | read -r -p "Are you sure you that want to continue upgrading to the stable (master) branch? [y/N] " response |
| 961 | if [[ ! "${response}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then |
| 962 | echo "OK. If you prepared yourself for that please run the update.sh Script with the --stable parameter again to trigger this process here." |
| 963 | exit 0 |
| 964 | fi |
| 965 | BRANCH=$NEW_BRANCH |
| 966 | DIFF_DIRECTORY=update_diffs |
| 967 | DIFF_FILE=${DIFF_DIRECTORY}/diff_before_upgrade_to_master_$(date +"%Y-%m-%d-%H-%M-%S") |
| 968 | mv diff_before_upgrade* ${DIFF_DIRECTORY}/ 2> /dev/null |
| 969 | if ! git diff-index --quiet HEAD; then |
| 970 | echo -e "\e[32mSaving diff to ${DIFF_FILE}...\e[0m" |
| 971 | mkdir -p ${DIFF_DIRECTORY} |
| 972 | git diff ${BRANCH} --stat > ${DIFF_FILE} |
| 973 | git diff ${BRANCH} >> ${DIFF_FILE} |
| 974 | fi |
| 975 | echo -e "\e[32mSwitching Branch to ${BRANCH}...\e[0m" |
| 976 | git fetch origin |
| 977 | git checkout -f ${BRANCH} |
| 978 | |
| 979 | elif [ $NEW_BRANCH == "nightly" ] && [ $CURRENT_BRANCH != "nightly" ]; then |
| 980 | echo -e "\e[33mYou are about to switch your mailcow Updates to the unstable (nightly) branch.\e[0m" |
| 981 | sleep 1 |
| 982 | echo -e "\e[33mBefore you do: Please take a backup of all components to ensure that no Data is lost...\e[0m" |
| 983 | sleep 1 |
| 984 | echo -e "\e[31mWARNING: A switch to nightly is possible any time. But a switch back (to master) isn't.\e[0m" |
| 985 | read -r -p "Are you sure you that want to continue upgrading to the unstable (nightly) branch? [y/N] " response |
| 986 | if [[ ! "${response}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then |
| 987 | echo "OK. If you prepared yourself for that please run the update.sh Script with the --nightly parameter again to trigger this process here." |
| 988 | exit 0 |
| 989 | fi |
| 990 | BRANCH=$NEW_BRANCH |
| 991 | DIFF_DIRECTORY=update_diffs |
| 992 | DIFF_FILE=${DIFF_DIRECTORY}/diff_before_upgrade_to_nightly_$(date +"%Y-%m-%d-%H-%M-%S") |
| 993 | mv diff_before_upgrade* ${DIFF_DIRECTORY}/ 2> /dev/null |
| 994 | if ! git diff-index --quiet HEAD; then |
| 995 | echo -e "\e[32mSaving diff to ${DIFF_FILE}...\e[0m" |
| 996 | mkdir -p ${DIFF_DIRECTORY} |
| 997 | git diff ${BRANCH} --stat > ${DIFF_FILE} |
| 998 | git diff ${BRANCH} >> ${DIFF_FILE} |
| 999 | fi |
| 1000 | git fetch origin |
| 1001 | git checkout -f ${BRANCH} |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1002 | fi |
| 1003 | |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame^] | 1004 | if [ ! $DEV ]; then |
| 1005 | echo -e "\e[32mChecking for newer update script...\e[0m" |
| 1006 | SHA1_1=$(sha1sum update.sh) |
| 1007 | git fetch origin #${BRANCH} |
| 1008 | git checkout origin/${BRANCH} update.sh |
| 1009 | SHA1_2=$(sha1sum update.sh) |
| 1010 | if [[ ${SHA1_1} != ${SHA1_2} ]]; then |
| 1011 | echo "update.sh changed, please run this script again, exiting." |
| 1012 | chmod +x update.sh |
| 1013 | exit 2 |
| 1014 | fi |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1015 | if [ ! $FORCE ]; then |
| 1016 | read -r -p "Are you sure you want to update mailcow: dockerized? All containers will be stopped. [y/N] " response |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 1017 | if [[ ! "${response}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1018 | echo "OK, exiting." |
| 1019 | exit 0 |
| 1020 | fi |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 1021 | migrate_docker_nat |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1022 | fi |
| 1023 | |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 1024 | remove_obsolete_nginx_ports |
| 1025 | |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1026 | echo -e "\e[32mValidating docker-compose stack configuration...\e[0m" |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 1027 | sed -i 's/HTTPS_BIND:-:/HTTPS_BIND:-/g' docker-compose.yml |
| 1028 | sed -i 's/HTTP_BIND:-:/HTTP_BIND:-/g' docker-compose.yml |
| 1029 | if ! $COMPOSE_COMMAND config -q; then |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1030 | echo -e "\e[31m\nOh no, something went wrong. Please check the error message above.\e[0m" |
| 1031 | exit 1 |
| 1032 | fi |
| 1033 | |
| 1034 | echo -e "\e[32mChecking for conflicting bridges...\e[0m" |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 1035 | MAILCOW_BRIDGE=$($COMPOSE_COMMAND config | grep -i com.docker.network.bridge.name | cut -d':' -f2) |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1036 | while read NAT_ID; do |
| 1037 | iptables -t nat -D POSTROUTING $NAT_ID |
| 1038 | done < <(iptables -L -vn -t nat --line-numbers | grep $IPV4_NETWORK | grep -E 'MASQUERADE.*all' | grep -v ${MAILCOW_BRIDGE} | cut -d' ' -f1) |
| 1039 | |
| 1040 | DIFF_DIRECTORY=update_diffs |
| 1041 | DIFF_FILE=${DIFF_DIRECTORY}/diff_before_update_$(date +"%Y-%m-%d-%H-%M-%S") |
| 1042 | mv diff_before_update* ${DIFF_DIRECTORY}/ 2> /dev/null |
| 1043 | if ! git diff-index --quiet HEAD; then |
| 1044 | echo -e "\e[32mSaving diff to ${DIFF_FILE}...\e[0m" |
| 1045 | mkdir -p ${DIFF_DIRECTORY} |
| 1046 | git diff --stat > ${DIFF_FILE} |
| 1047 | git diff >> ${DIFF_FILE} |
| 1048 | fi |
| 1049 | |
| 1050 | echo -e "\e[32mPrefetching images...\e[0m" |
| 1051 | prefetch_images |
| 1052 | |
| 1053 | echo -e "\e[32mStopping mailcow...\e[0m" |
| 1054 | sleep 2 |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 1055 | MAILCOW_CONTAINERS=($($COMPOSE_COMMAND ps -q)) |
| 1056 | $COMPOSE_COMMAND down |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1057 | echo -e "\e[32mChecking for remaining containers...\e[0m" |
| 1058 | sleep 2 |
| 1059 | for container in "${MAILCOW_CONTAINERS[@]}"; do |
| 1060 | docker rm -f "$container" 2> /dev/null |
| 1061 | done |
| 1062 | |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 1063 | [[ -f data/conf/nginx/ZZZ-ejabberd.conf ]] && rm data/conf/nginx/ZZZ-ejabberd.conf |
| 1064 | |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame^] | 1065 | |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1066 | # Silently fixing remote url from andryyy to mailcow |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame^] | 1067 | # git remote set-url origin https://github.com/mailcow/mailcow-dockerized |
| 1068 | |
| 1069 | DEFAULT_REPO=https://github.com/mailcow/mailcow-dockerized |
| 1070 | CURRENT_REPO=$(git remote get-url origin) |
| 1071 | if [ "$CURRENT_REPO" != "$DEFAULT_REPO" ]; then |
| 1072 | echo "The Repository currently used is not the default Mailcow Repository." |
| 1073 | echo "Currently Repository: $CURRENT_REPO" |
| 1074 | echo "Default Repository: $DEFAULT_REPO" |
| 1075 | read -r -p "Should it be changed back to default? [y/N] " repo_response |
| 1076 | if [[ "$repo_response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then |
| 1077 | git remote set-url origin $DEFAULT_REPO |
| 1078 | fi |
| 1079 | fi |
| 1080 | |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1081 | echo -e "\e[32mCommitting current status...\e[0m" |
| 1082 | [[ -z "$(git config user.name)" ]] && git config user.name moo |
| 1083 | [[ -z "$(git config user.email)" ]] && git config user.email moo@cow.moo |
| 1084 | [[ ! -z $(git ls-files data/conf/rspamd/override.d/worker-controller-password.inc) ]] && git rm data/conf/rspamd/override.d/worker-controller-password.inc |
| 1085 | git add -u |
| 1086 | git commit -am "Before update on ${DATE}" > /dev/null |
| 1087 | echo -e "\e[32mFetching updated code from remote...\e[0m" |
| 1088 | git fetch origin #${BRANCH} |
| 1089 | echo -e "\e[32mMerging local with remote code (recursive, strategy: \"${MERGE_STRATEGY:-theirs}\", options: \"patience\"...\e[0m" |
| 1090 | git config merge.defaultToUpstream true |
| 1091 | git merge -X${MERGE_STRATEGY:-theirs} -Xpatience -m "After update on ${DATE}" |
| 1092 | # Need to use a variable to not pass return codes of if checks |
| 1093 | MERGE_RETURN=$? |
| 1094 | if [[ ${MERGE_RETURN} == 128 ]]; then |
| 1095 | echo -e "\e[31m\nOh no, what happened?\n=> You most likely added files to your local mailcow instance that were now added to the official mailcow repository. Please move them to another location before updating mailcow.\e[0m" |
| 1096 | exit 1 |
| 1097 | elif [[ ${MERGE_RETURN} == 1 ]]; then |
| 1098 | echo -e "\e[93mPotenial conflict, trying to fix...\e[0m" |
| 1099 | git status --porcelain | grep -E "UD|DU" | awk '{print $2}' | xargs rm -v |
| 1100 | git add -A |
| 1101 | git commit -m "After update on ${DATE}" > /dev/null |
| 1102 | git checkout . |
| 1103 | echo -e "\e[32mRemoved and recreated files if necessary.\e[0m" |
| 1104 | elif [[ ${MERGE_RETURN} != 0 ]]; then |
| 1105 | echo -e "\e[31m\nOh no, something went wrong. Please check the error message above.\e[0m" |
| 1106 | echo |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 1107 | echo "Run $COMPOSE_COMMAND up -d to restart your stack without updates or try again after fixing the mentioned errors." |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1108 | exit 1 |
| 1109 | fi |
| 1110 | |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1111 | echo -e "\e[32mFetching new images, if any...\e[0m" |
| 1112 | sleep 2 |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 1113 | $COMPOSE_COMMAND pull |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1114 | |
| 1115 | # Fix missing SSL, does not overwrite existing files |
| 1116 | [[ ! -d data/assets/ssl ]] && mkdir -p data/assets/ssl |
| 1117 | cp -n -d data/assets/ssl-example/*.pem data/assets/ssl/ |
| 1118 | |
| 1119 | echo -e "Checking IPv6 settings... " |
| 1120 | if grep -q 'SYSCTL_IPV6_DISABLED=1' mailcow.conf; then |
| 1121 | echo |
| 1122 | echo '!! IMPORTANT !!' |
| 1123 | echo |
| 1124 | echo 'SYSCTL_IPV6_DISABLED was removed due to complications. IPv6 can be disabled by editing "docker-compose.yml" and setting "enable_ipv6: true" to "enable_ipv6: false".' |
Matthias Andreas Benkard | d1f5b68 | 2023-11-18 13:18:30 +0100 | [diff] [blame^] | 1125 | echo "This setting will only be active after a complete shutdown of mailcow by running $COMPOSE_COMMAND down followed by $COMPOSE_COMMAND up -d." |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1126 | echo |
| 1127 | echo '!! IMPORTANT !!' |
| 1128 | echo |
| 1129 | read -p "Press any key to continue..." < /dev/tty |
| 1130 | fi |
| 1131 | |
| 1132 | # Checking for old project name bug |
| 1133 | sed -i --follow-symlinks 's#COMPOSEPROJECT_NAME#COMPOSE_PROJECT_NAME#g' mailcow.conf |
| 1134 | |
| 1135 | # Fix Rspamd maps |
| 1136 | if [ -f data/conf/rspamd/custom/global_from_blacklist.map ]; then |
| 1137 | mv data/conf/rspamd/custom/global_from_blacklist.map data/conf/rspamd/custom/global_smtp_from_blacklist.map |
| 1138 | fi |
| 1139 | if [ -f data/conf/rspamd/custom/global_from_whitelist.map ]; then |
| 1140 | mv data/conf/rspamd/custom/global_from_whitelist.map data/conf/rspamd/custom/global_smtp_from_whitelist.map |
| 1141 | fi |
| 1142 | |
| 1143 | # Fix deprecated metrics.conf |
| 1144 | if [ -f "data/conf/rspamd/local.d/metrics.conf" ]; then |
| 1145 | if [ ! -z "$(git diff --name-only origin/master data/conf/rspamd/local.d/metrics.conf)" ]; then |
| 1146 | echo -e "\e[33mWARNING\e[0m - Please migrate your customizations of data/conf/rspamd/local.d/metrics.conf to actions.conf and groups.conf after this update." |
| 1147 | echo "The deprecated configuration file metrics.conf will be moved to metrics.conf_deprecated after updating mailcow." |
| 1148 | fi |
| 1149 | mv data/conf/rspamd/local.d/metrics.conf data/conf/rspamd/local.d/metrics.conf_deprecated |
| 1150 | fi |
| 1151 | |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 1152 | # Set app_info.inc.php |
| 1153 | if [ ${BRANCH} == "master" ]; then |
| 1154 | mailcow_git_version=$(git describe --tags `git rev-list --tags --max-count=1`) |
| 1155 | elif [ ${BRANCH} == "nightly" ]; then |
| 1156 | mailcow_git_version=$(git rev-parse --short $(git rev-parse @{upstream})) |
| 1157 | mailcow_last_git_version="" |
| 1158 | else |
| 1159 | mailcow_git_version=$(git rev-parse --short HEAD) |
| 1160 | mailcow_last_git_version="" |
| 1161 | fi |
| 1162 | |
| 1163 | mailcow_git_commit=$(git rev-parse origin/${BRANCH}) |
| 1164 | mailcow_git_commit_date=$(git log -1 --format=%ci @{upstream} ) |
| 1165 | |
| 1166 | if [ $? -eq 0 ]; then |
| 1167 | echo '<?php' > data/web/inc/app_info.inc.php |
| 1168 | echo ' $MAILCOW_GIT_VERSION="'$mailcow_git_version'";' >> data/web/inc/app_info.inc.php |
| 1169 | echo ' $MAILCOW_LAST_GIT_VERSION="";' >> data/web/inc/app_info.inc.php |
| 1170 | echo ' $MAILCOW_GIT_OWNER="mailcow";' >> data/web/inc/app_info.inc.php |
| 1171 | echo ' $MAILCOW_GIT_REPO="mailcow-dockerized";' >> data/web/inc/app_info.inc.php |
| 1172 | echo ' $MAILCOW_GIT_URL="https://github.com/mailcow/mailcow-dockerized";' >> data/web/inc/app_info.inc.php |
| 1173 | echo ' $MAILCOW_GIT_COMMIT="'$mailcow_git_commit'";' >> data/web/inc/app_info.inc.php |
| 1174 | echo ' $MAILCOW_GIT_COMMIT_DATE="'$mailcow_git_commit_date'";' >> data/web/inc/app_info.inc.php |
| 1175 | echo ' $MAILCOW_BRANCH="'$BRANCH'";' >> data/web/inc/app_info.inc.php |
| 1176 | echo ' $MAILCOW_UPDATEDAT='$(date +%s)';' >> data/web/inc/app_info.inc.php |
| 1177 | echo '?>' >> data/web/inc/app_info.inc.php |
| 1178 | else |
| 1179 | echo '<?php' > data/web/inc/app_info.inc.php |
| 1180 | echo ' $MAILCOW_GIT_VERSION="'$mailcow_git_version'";' >> data/web/inc/app_info.inc.php |
| 1181 | echo ' $MAILCOW_LAST_GIT_VERSION="";' >> data/web/inc/app_info.inc.php |
| 1182 | echo ' $MAILCOW_GIT_OWNER="mailcow";' >> data/web/inc/app_info.inc.php |
| 1183 | echo ' $MAILCOW_GIT_REPO="mailcow-dockerized";' >> data/web/inc/app_info.inc.php |
| 1184 | echo ' $MAILCOW_GIT_URL="https://github.com/mailcow/mailcow-dockerized";' >> data/web/inc/app_info.inc.php |
| 1185 | echo ' $MAILCOW_GIT_COMMIT="";' >> data/web/inc/app_info.inc.php |
| 1186 | echo ' $MAILCOW_GIT_COMMIT_DATE="";' >> data/web/inc/app_info.inc.php |
| 1187 | echo ' $MAILCOW_BRANCH="'$BRANCH'";' >> data/web/inc/app_info.inc.php |
| 1188 | echo ' $MAILCOW_UPDATEDAT='$(date +%s)';' >> data/web/inc/app_info.inc.php |
| 1189 | echo '?>' >> data/web/inc/app_info.inc.php |
| 1190 | echo -e "\e[33mCannot determine current git repository version...\e[0m" |
| 1191 | fi |
| 1192 | |
| 1193 | # Set DOCKER_COMPOSE_VERSION |
| 1194 | sed -i 's/^DOCKER_COMPOSE_VERSION=$/DOCKER_COMPOSE_VERSION='$DOCKER_COMPOSE_VERSION'/g' mailcow.conf |
| 1195 | |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1196 | if [[ ${SKIP_START} == "y" ]]; then |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 1197 | echo -e "\e[33mNot starting mailcow, please run \"$COMPOSE_COMMAND up -d --remove-orphans\" to start mailcow.\e[0m" |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1198 | else |
| 1199 | echo -e "\e[32mStarting mailcow...\e[0m" |
| 1200 | sleep 2 |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 1201 | $COMPOSE_COMMAND up -d --remove-orphans |
Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1202 | fi |
| 1203 | |
| 1204 | echo -e "\e[32mCollecting garbage...\e[0m" |
| 1205 | docker_garbage |
| 1206 | |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 1207 | # Run post-update-hook |
| 1208 | if [ -f "${SCRIPT_DIR}/post_update_hook.sh" ]; then |
| 1209 | bash "${SCRIPT_DIR}/post_update_hook.sh" |
| 1210 | fi |
| 1211 | |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 1212 | # echo "In case you encounter any problem, hard-reset to a state before updating mailcow:" |
| 1213 | # echo |
| 1214 | # git reflog --color=always | grep "Before update on " |
| 1215 | # echo |
| 1216 | # echo "Use \"git reset --hard hash-on-the-left\" and run $COMPOSE_COMMAND up -d afterwards." |