| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 3 | # Ensure the script is run from the directory that contains a link of .env |
| 4 | # Resolve the directory this script lives in for consistent behavior when invoked from elsewhere |
| 5 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" >/dev/null 2>&1 && pwd)" |
| 6 | |
| 7 | # Ensure script is executed in the mailcow installation directory by checking for a .env symlink that points to mailcow.conf |
| 8 | if [ ! -L "${PWD}/.env" ]; then |
| 9 | echo -e "\e[33mPlease run this script from the mailcow installation directory.\e[0m" |
| 10 | echo -e " \e[36mcd /path/to/mailcow && ./generate_config.sh\e[0m" |
| 11 | exit 1 |
| 12 | fi |
| 13 | |
| 14 | # Verify the .env symlink points to a mailcow.conf file |
| 15 | env_target="$(readlink -f "${PWD}/.env" 2>/dev/null || true)" |
| 16 | if [ -z "$env_target" ] || [ "$(basename "$env_target")" != "mailcow.conf" ]; then |
| 17 | echo -e "\e[31mThe found .env symlink does not point to a mailcow.conf file.\e[0m" |
| 18 | echo -e "\e[33mPlease create a symbolic link .env -> mailcow.conf inside the mailcow directory and run this script there.\e[0m" |
| 19 | echo -e "\e[33mNote: 'ln -s mailcow.conf .env' will create the symlink even if mailcow.conf does not yet exist.\e[0m" |
| 20 | echo -e " \e[36mcd /path/to/mailcow && ln -s mailcow.conf .env && ./generate_config.sh\e[0m" |
| 21 | exit 1 |
| 22 | fi |
| 23 | |
| 24 | # Load mailcow Generic Scripts |
| 25 | source _modules/scripts/core.sh |
| 26 | source _modules/scripts/ipv6_controller.sh |
| 27 | |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 28 | set -o pipefail |
| 29 | |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 30 | get_installed_tools |
| 31 | get_docker_version |
| 32 | |
| 33 | if [[ $docker_version -lt 24 ]]; then |
| 34 | echo -e "\e[31mCannot find Docker with a Version higher or equals 24.0.0\e[0m" |
| 35 | echo -e "\e[33mmailcow needs a newer Docker version to work properly...\e[0m" |
| 36 | echo -e "\e[31mPlease update your Docker installation... exiting\e[0m" |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 37 | exit 1 |
| 38 | fi |
| 39 | |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 40 | detect_bad_asn |
| Matthias Andreas Benkard | d63fe56 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 41 | |
| 42 | ### If generate_config.sh is started with --dev or -d it will not check out nightly or master branch and will keep on the current branch |
| 43 | if [[ ${1} == "--dev" || ${1} == "-d" ]]; then |
| 44 | SKIP_BRANCH=y |
| 45 | else |
| 46 | SKIP_BRANCH=n |
| 47 | fi |
| Matthias Andreas Benkard | 3c18a08 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 48 | |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 49 | if [ -f mailcow.conf ]; then |
| Matthias Andreas Benkard | 8f91594 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 50 | read -r -p "A config file exists and will be overwritten, are you sure you want to continue? [y/N] " response |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 51 | case $response in |
| 52 | [yY][eE][sS]|[yY]) |
| 53 | mv mailcow.conf mailcow.conf_backup |
| 54 | chmod 600 mailcow.conf_backup |
| 55 | ;; |
| 56 | *) |
| 57 | exit 1 |
| 58 | ;; |
| 59 | esac |
| 60 | fi |
| 61 | |
| 62 | echo "Press enter to confirm the detected value '[value]' where applicable or enter a custom value." |
| 63 | while [ -z "${MAILCOW_HOSTNAME}" ]; do |
| 64 | read -p "Mail server hostname (FQDN) - this is not your mail domain, but your mail servers hostname: " -e MAILCOW_HOSTNAME |
| 65 | DOTS=${MAILCOW_HOSTNAME//[^.]}; |
| Matthias Andreas Benkard | d63fe56 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 66 | if [ ${#DOTS} -lt 1 ]; then |
| 67 | echo -e "\e[31mMAILCOW_HOSTNAME (${MAILCOW_HOSTNAME}) is not a FQDN!\e[0m" |
| 68 | sleep 1 |
| 69 | echo "Please change it to a FQDN and redeploy the stack with docker(-)compose up -d" |
| 70 | exit 1 |
| 71 | elif [[ "${MAILCOW_HOSTNAME: -1}" == "." ]]; then |
| 72 | echo "MAILCOW_HOSTNAME (${MAILCOW_HOSTNAME}) is ending with a dot. This is not a valid FQDN!" |
| 73 | exit 1 |
| 74 | elif [ ${#DOTS} -eq 1 ]; then |
| 75 | echo -e "\e[33mMAILCOW_HOSTNAME (${MAILCOW_HOSTNAME}) does not contain a Subdomain. This is not fully tested and may cause issues.\e[0m" |
| 76 | echo "Find more information about why this message exists here: https://github.com/mailcow/mailcow-dockerized/issues/1572" |
| 77 | read -r -p "Do you want to proceed anyway? [y/N] " response |
| 78 | if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then |
| 79 | echo "OK. Procceding." |
| 80 | else |
| 81 | echo "OK. Exiting." |
| 82 | exit 1 |
| 83 | fi |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 84 | fi |
| 85 | done |
| 86 | |
| 87 | if [ -a /etc/timezone ]; then |
| 88 | DETECTED_TZ=$(cat /etc/timezone) |
| 89 | elif [ -a /etc/localtime ]; then |
| 90 | DETECTED_TZ=$(readlink /etc/localtime|sed -n 's|^.*zoneinfo/||p') |
| 91 | fi |
| 92 | |
| 93 | while [ -z "${MAILCOW_TZ}" ]; do |
| 94 | if [ -z "${DETECTED_TZ}" ]; then |
| 95 | read -p "Timezone: " -e MAILCOW_TZ |
| 96 | else |
| 97 | read -p "Timezone [${DETECTED_TZ}]: " -e MAILCOW_TZ |
| 98 | [ -z "${MAILCOW_TZ}" ] && MAILCOW_TZ=${DETECTED_TZ} |
| 99 | fi |
| 100 | done |
| 101 | |
| 102 | MEM_TOTAL=$(awk '/MemTotal/ {print $2}' /proc/meminfo) |
| 103 | |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 104 | if [ -z "${SKIP_CLAMD}" ]; then |
| 105 | if [ "${MEM_TOTAL}" -le "2621440" ]; then |
| 106 | echo "Installed memory is <= 2.5 GiB. It is recommended to disable ClamAV to prevent out-of-memory situations." |
| 107 | echo "ClamAV can be re-enabled by setting SKIP_CLAMD=n in mailcow.conf." |
| 108 | read -r -p "Do you want to disable ClamAV now? [Y/n] " response |
| 109 | case $response in |
| 110 | [nN][oO]|[nN]) |
| 111 | SKIP_CLAMD=n |
| 112 | ;; |
| 113 | *) |
| 114 | SKIP_CLAMD=y |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 115 | ;; |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 116 | esac |
| 117 | else |
| 118 | SKIP_CLAMD=n |
| 119 | fi |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 120 | fi |
| 121 | |
| Matthias Andreas Benkard | d63fe56 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 122 | if [[ ${SKIP_BRANCH} != y ]]; then |
| 123 | echo "Which branch of mailcow do you want to use?" |
| 124 | echo "" |
| 125 | echo "Available Branches:" |
| 126 | echo "- master branch (stable updates) | default, recommended [1]" |
| 127 | echo "- nightly branch (unstable updates, testing) | not-production ready [2]" |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 128 | echo "- legacy branch (supported until February 2026) | deprecated, security updates only [3]" |
| Matthias Andreas Benkard | d63fe56 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 129 | sleep 1 |
| Matthias Andreas Benkard | 3c18a08 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 130 | |
| Matthias Andreas Benkard | d63fe56 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 131 | while [ -z "${MAILCOW_BRANCH}" ]; do |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 132 | read -r -p "Choose the Branch with it's number [1/2/3] " branch |
| Matthias Andreas Benkard | d63fe56 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 133 | case $branch in |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 134 | [3]) |
| 135 | MAILCOW_BRANCH="legacy" |
| 136 | ;; |
| Matthias Andreas Benkard | d63fe56 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 137 | [2]) |
| 138 | MAILCOW_BRANCH="nightly" |
| 139 | ;; |
| 140 | *) |
| 141 | MAILCOW_BRANCH="master" |
| Matthias Andreas Benkard | 3c18a08 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 142 | ;; |
| Matthias Andreas Benkard | d63fe56 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 143 | esac |
| 144 | done |
| 145 | |
| 146 | git fetch --all |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 147 | git checkout -f "$MAILCOW_BRANCH" |
| Matthias Andreas Benkard | d63fe56 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 148 | |
| 149 | elif [[ ${SKIP_BRANCH} == y ]]; then |
| 150 | echo -e "\033[33mEnabled Dev Mode.\033[0m" |
| 151 | echo -e "\033[33mNot checking out a different branch!\033[0m" |
| 152 | MAILCOW_BRANCH=$(git rev-parse --short $(git rev-parse @{upstream})) |
| 153 | |
| 154 | else |
| 155 | echo -e "\033[31mCould not determine branch input..." |
| 156 | echo -e "\033[31mExiting." |
| 157 | exit 1 |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 158 | fi |
| Matthias Andreas Benkard | 3c18a08 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 159 | |
| 160 | if [ ! -z "${MAILCOW_BRANCH}" ]; then |
| 161 | git_branch=${MAILCOW_BRANCH} |
| 162 | fi |
| 163 | |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 164 | configure_ipv6 |
| 165 | |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 166 | [ ! -f ./data/conf/rspamd/override.d/worker-controller-password.inc ] && echo '# Placeholder' > ./data/conf/rspamd/override.d/worker-controller-password.inc |
| 167 | |
| 168 | cat << EOF > mailcow.conf |
| 169 | # ------------------------------ |
| 170 | # mailcow web ui configuration |
| 171 | # ------------------------------ |
| 172 | # example.org is _not_ a valid hostname, use a fqdn here. |
| 173 | # Default admin user is "admin" |
| 174 | # Default password is "moohoo" |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 175 | MAILCOW_HOSTNAME=${MAILCOW_HOSTNAME} |
| 176 | |
| 177 | # Password hash algorithm |
| 178 | # Only certain password hash algorithm are supported. For a fully list of supported schemes, |
| Matthias Andreas Benkard | d63fe56 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 179 | # see https://docs.mailcow.email/models/model-passwd/ |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 180 | MAILCOW_PASS_SCHEME=BLF-CRYPT |
| 181 | |
| 182 | # ------------------------------ |
| 183 | # SQL database configuration |
| 184 | # ------------------------------ |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 185 | DBNAME=mailcow |
| 186 | DBUSER=mailcow |
| 187 | |
| 188 | # Please use long, random alphanumeric strings (A-Za-z0-9) |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 189 | DBPASS=${MAILCOW_DBPASS:-$(LC_ALL=C </dev/urandom tr -dc A-Za-z0-9 2> /dev/null | head -c 28)} |
| 190 | DBROOT=${MAILCOW_DBROOT:-$(LC_ALL=C </dev/urandom tr -dc A-Za-z0-9 2> /dev/null | head -c 28)} |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 191 | |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 192 | # ------------------------------ |
| 193 | # REDIS configuration |
| 194 | # ------------------------------ |
| 195 | REDISPASS=${MAILCOW_REDISPASS:-$(LC_ALL=C </dev/urandom tr -dc A-Za-z0-9 2> /dev/null | head -c 28)} |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 196 | |
| 197 | # ------------------------------ |
| 198 | # HTTP/S Bindings |
| 199 | # ------------------------------ |
| 200 | |
| 201 | # You should use HTTPS, but in case of SSL offloaded reverse proxies: |
| 202 | # Might be important: This will also change the binding within the container. |
| 203 | # If you use a proxy within Docker, point it to the ports you set below. |
| 204 | # Do _not_ use IP:PORT in HTTP(S)_BIND or HTTP(S)_PORT |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 205 | # IMPORTANT: Do not use port 8081, 9081, 9082 or 65510! |
| Matthias Andreas Benkard | 8f91594 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 206 | # Example: HTTP_BIND=1.2.3.4 |
| Matthias Andreas Benkard | 3c18a08 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 207 | # For IPv4 leave it as it is: HTTP_BIND= & HTTPS_PORT= |
| Matthias Andreas Benkard | d63fe56 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 208 | # For IPv6 see https://docs.mailcow.email/post_installation/firststeps-ip_bindings/ |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 209 | HTTP_PORT=80 |
| Matthias Andreas Benkard | 8f91594 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 210 | HTTP_BIND= |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 211 | |
| 212 | HTTPS_PORT=443 |
| Matthias Andreas Benkard | 8f91594 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 213 | HTTPS_BIND= |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 214 | |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 215 | # Redirect HTTP connections to HTTPS - y/n |
| 216 | HTTP_REDIRECT=y |
| 217 | |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 218 | # ------------------------------ |
| 219 | # Other bindings |
| 220 | # ------------------------------ |
| 221 | # You should leave that alone |
| Matthias Andreas Benkard | 8f91594 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 222 | # Format: 11.22.33.44:25 or 12.34.56.78:465 etc. |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 223 | SMTP_PORT=25 |
| 224 | SMTPS_PORT=465 |
| 225 | SUBMISSION_PORT=587 |
| 226 | IMAP_PORT=143 |
| 227 | IMAPS_PORT=993 |
| 228 | POP_PORT=110 |
| 229 | POPS_PORT=995 |
| 230 | SIEVE_PORT=4190 |
| 231 | DOVEADM_PORT=127.0.0.1:19991 |
| 232 | SQL_PORT=127.0.0.1:13306 |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 233 | REDIS_PORT=127.0.0.1:7654 |
| 234 | |
| 235 | # Your timezone |
| 236 | # See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a list of timezones |
| Matthias Andreas Benkard | d63fe56 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 237 | # Use the column named 'TZ identifier' + pay attention for the column named 'Notes' |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 238 | TZ=${MAILCOW_TZ} |
| 239 | |
| 240 | # Fixed project name |
| 241 | # Please use lowercase letters only |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 242 | COMPOSE_PROJECT_NAME=mailcowdockerized |
| 243 | |
| Matthias Andreas Benkard | 3c18a08 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 244 | # Used Docker Compose version |
| 245 | # Switch here between native (compose plugin) and standalone |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 246 | # For more information take a look at the mailcow docs regarding the configuration options. |
| Matthias Andreas Benkard | 3c18a08 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 247 | # Normally this should be untouched but if you decided to use either of those you can switch it manually here. |
| Matthias Andreas Benkard | d63fe56 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 248 | # Please be aware that at least one of those variants should be installed on your machine or mailcow will fail. |
| Matthias Andreas Benkard | 3c18a08 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 249 | DOCKER_COMPOSE_VERSION=${COMPOSE_VERSION} |
| 250 | |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 251 | # Set this to "allow" to enable the anyone pseudo user. Disabled by default. |
| 252 | # When enabled, ACL can be created, that apply to "All authenticated users" |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 253 | # This should probably only be activated on mail hosts, that are used exclusively by one organisation. |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 254 | # Otherwise a user might share data with too many other users. |
| 255 | ACL_ANYONE=disallow |
| 256 | |
| 257 | # Garbage collector cleanup |
| 258 | # Deleted domains and mailboxes are moved to /var/vmail/_garbage/timestamp_sanitizedstring |
| 259 | # How long should objects remain in the garbage until they are being deleted? (value in minutes) |
| 260 | # Check interval is hourly |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 261 | MAILDIR_GC_TIME=7200 |
| 262 | |
| 263 | # Additional SAN for the certificate |
| 264 | # |
| 265 | # You can use wildcard records to create specific names for every domain you add to mailcow. |
| 266 | # Example: Add domains "example.com" and "example.net" to mailcow, change ADDITIONAL_SAN to a value like: |
| 267 | #ADDITIONAL_SAN=imap.*,smtp.* |
| Matthias Andreas Benkard | 3c18a08 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 268 | # This will expand the certificate to "imap.example.com", "smtp.example.com", "imap.example.net", "smtp.example.net" |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 269 | # plus every domain you add in the future. |
| 270 | # |
| 271 | # You can also just add static names... |
| 272 | #ADDITIONAL_SAN=srv1.example.net |
| 273 | # ...or combine wildcard and static names: |
| 274 | #ADDITIONAL_SAN=imap.*,srv1.example.com |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 275 | ADDITIONAL_SAN= |
| 276 | |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 277 | # Obtain certificates for autodiscover.* and autoconfig.* domains. |
| 278 | # This can be useful to switch off in case you are in a scenario where a reverse proxy already handles those. |
| 279 | # There are mixed scenarios where ports 80,443 are occupied and you do not want to share certs |
| 280 | # between services. So acme-mailcow obtains for maildomains and all web-things get handled |
| 281 | # in the reverse proxy. |
| 282 | AUTODISCOVER_SAN=y |
| 283 | |
| Matthias Andreas Benkard | 8f91594 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 284 | # Additional server names for mailcow UI |
| 285 | # |
| 286 | # Specify alternative addresses for the mailcow UI to respond to |
| 287 | # 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. |
| 288 | # If the server name does not match a known site, Nginx decides by best-guess and may redirect users to the wrong web root. |
| 289 | # You can understand this as server_name directive in Nginx. |
| 290 | # Comma separated list without spaces! Example: ADDITIONAL_SERVER_NAMES=a.b.c,d.e.f |
| Matthias Andreas Benkard | 8f91594 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 291 | ADDITIONAL_SERVER_NAMES= |
| 292 | |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 293 | # Skip running ACME (acme-mailcow, Let's Encrypt certs) - y/n |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 294 | SKIP_LETS_ENCRYPT=n |
| 295 | |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 296 | # Enable DNS-01 challenge for ACME (acme-mailcow) - y/n |
| 297 | # This requires you to set ACME_DNS_PROVIDER and ACME_ACCOUNT_EMAIL below |
| 298 | ACME_DNS_CHALLENGE=n |
| 299 | ACME_DNS_PROVIDER=dns_xxx |
| 300 | ACME_ACCOUNT_EMAIL=me@example.com |
| 301 | # You will need to pass provider-specific environment variables to the acme-mailcow container. |
| 302 | # See the dns-01 provider documentation for more information. |
| 303 | # for example for Azure DNS: |
| 304 | #AZUREDNS_SUBSCRIPTIONID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx |
| 305 | #AZUREDNS_TENANTID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx |
| 306 | #AZUREDNS_APPID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx |
| 307 | #AZUREDNS_CLIENTSECRET=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx |
| 308 | #AZUREDNS_RESOURCEGROUP="your-resource-group" |
| 309 | #AZUREDNS_ZONE="your-zone-name" |
| 310 | |
| 311 | # Create separate certificates for all domains - y/n |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 312 | # this will allow adding more than 100 domains, but some email clients will not be able to connect with alternative hostnames |
| Matthias Andreas Benkard | d63fe56 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 313 | # see https://doc.dovecot.org/admin_manual/ssl/sni_support |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 314 | ENABLE_SSL_SNI=n |
| 315 | |
| 316 | # Skip IPv4 check in ACME container - y/n |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 317 | SKIP_IP_CHECK=n |
| 318 | |
| 319 | # Skip HTTP verification in ACME container - y/n |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 320 | SKIP_HTTP_VERIFICATION=n |
| 321 | |
| Matthias Andreas Benkard | 9dabdab | 2024-03-06 13:12:09 +0100 | [diff] [blame] | 322 | # Skip Unbound (DNS Resolver) Healthchecks (NOT Recommended!) - y/n |
| Matthias Andreas Benkard | 9dabdab | 2024-03-06 13:12:09 +0100 | [diff] [blame] | 323 | SKIP_UNBOUND_HEALTHCHECK=n |
| 324 | |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 325 | # Skip ClamAV (clamd-mailcow) anti-virus (Rspamd will auto-detect a missing ClamAV container) - y/n |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 326 | SKIP_CLAMD=${SKIP_CLAMD} |
| 327 | |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 328 | # Skip Olefy (olefy-mailcow) anti-virus for Office documents (Rspamd will auto-detect a missing Olefy container) - y/n |
| 329 | SKIP_OLEFY=n |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 330 | |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 331 | # Skip SOGo: Will disable SOGo integration and therefore webmail, DAV protocols and ActiveSync support (experimental, unsupported, not fully implemented) - y/n |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 332 | SKIP_SOGO=n |
| 333 | |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 334 | # Skip FTS (Fulltext Search) for Dovecot on low-memory, low-threaded systems or if you simply want to disable it. |
| 335 | # Dovecot inside mailcow use Flatcurve as FTS Backend. |
| 336 | SKIP_FTS=n |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 337 | |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 338 | # Dovecot Indexing (FTS) Process maximum heap size in MB, there is no recommendation, please see Dovecot docs. |
| 339 | # Flatcurve (Xapian backend) is used as the FTS Indexer. It is supposed to be efficient in CPU and RAM consumption. |
| 340 | # However: Please always monitor your Resource consumption! |
| 341 | FTS_HEAP=128 |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 342 | |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 343 | # Controls how many processes the Dovecot indexing process can spawn at max. |
| 344 | # Too many indexing processes can use a lot of CPU and Disk I/O. |
| 345 | # Please visit: https://doc.dovecot.org/configuration_manual/service_configuration/#indexer-worker for more information |
| 346 | FTS_PROCS=1 |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 347 | |
| 348 | # Allow admins to log into SOGo as email user (without any password) |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 349 | ALLOW_ADMIN_EMAIL_LOGIN=n |
| 350 | |
| 351 | # Enable watchdog (watchdog-mailcow) to restart unhealthy containers |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 352 | USE_WATCHDOG=y |
| 353 | |
| 354 | # Send watchdog notifications by mail (sent from watchdog@MAILCOW_HOSTNAME) |
| 355 | # CAUTION: |
| 356 | # 1. You should use external recipients |
| 357 | # 2. Mails are sent unsigned (no DKIM) |
| 358 | # 3. If you use DMARC, create a separate DMARC policy ("v=DMARC1; p=none;" in _dmarc.MAILCOW_HOSTNAME) |
| 359 | # Multiple rcpts allowed, NO quotation marks, NO spaces |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 360 | #WATCHDOG_NOTIFY_EMAIL=a@example.com,b@example.com,c@example.com |
| 361 | #WATCHDOG_NOTIFY_EMAIL= |
| 362 | |
| Matthias Andreas Benkard | 9dabdab | 2024-03-06 13:12:09 +0100 | [diff] [blame] | 363 | # Send notifications to a webhook URL that receives a POST request with the content type "application/json". |
| 364 | # You can use this to send notifications to services like Discord, Slack and others. |
| 365 | #WATCHDOG_NOTIFY_WEBHOOK=https://discord.com/api/webhooks/XXXXXXXXXXXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
| 366 | # JSON body included in the webhook POST request. Needs to be in single quotes. |
| 367 | # Following variables are available: SUBJECT, BODY |
| 368 | #WATCHDOG_NOTIFY_WEBHOOK_BODY='{"username": "mailcow Watchdog", "content": "**${SUBJECT}**\n${BODY}"}' |
| 369 | |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 370 | # Notify about banned IP (includes whois lookup) |
| 371 | WATCHDOG_NOTIFY_BAN=n |
| 372 | |
| Matthias Andreas Benkard | 9dabdab | 2024-03-06 13:12:09 +0100 | [diff] [blame] | 373 | # Send a notification when the watchdog is started. |
| 374 | WATCHDOG_NOTIFY_START=y |
| 375 | |
| Matthias Andreas Benkard | 8f91594 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 376 | # Subject for watchdog mails. Defaults to "Watchdog ALERT" followed by the error message. |
| 377 | #WATCHDOG_SUBJECT= |
| 378 | |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 379 | # Checks if mailcow is an open relay. Requires a SAL. More checks will follow. |
| 380 | # https://www.servercow.de/mailcow?lang=en |
| 381 | # https://www.servercow.de/mailcow?lang=de |
| 382 | # No data is collected. Opt-in and anonymous. |
| 383 | # Will only work with unmodified mailcow setups. |
| 384 | WATCHDOG_EXTERNAL_CHECKS=n |
| 385 | |
| Matthias Andreas Benkard | b4b5cc1 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 386 | # Enable watchdog verbose logging |
| 387 | WATCHDOG_VERBOSE=n |
| 388 | |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 389 | # Max log lines per service to keep in Redis logs |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 390 | LOG_LINES=9999 |
| 391 | |
| 392 | # Internal IPv4 /24 subnet, format n.n.n (expands to n.n.n.0/24) |
| 393 | # Use private IPv4 addresses only, see https://en.wikipedia.org/wiki/Private_network#Private_IPv4_addresses |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 394 | IPV4_NETWORK=172.22.1 |
| 395 | |
| 396 | # Internal IPv6 subnet in fc00::/7 |
| 397 | # Use private IPv6 addresses only, see https://en.wikipedia.org/wiki/Private_network#Private_IPv6_addresses |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 398 | IPV6_NETWORK=fd4d:6169:6c63:6f77::/64 |
| 399 | |
| 400 | # Use this IPv4 for outgoing connections (SNAT) |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 401 | #SNAT_TO_SOURCE= |
| 402 | |
| 403 | # Use this IPv6 for outgoing connections (SNAT) |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 404 | #SNAT6_TO_SOURCE= |
| 405 | |
| 406 | # Create or override an API key for the web UI |
| 407 | # You _must_ define API_ALLOW_FROM, which is a comma separated list of IPs |
| 408 | # An API key defined as API_KEY has read-write access |
| 409 | # An API key defined as API_KEY_READ_ONLY has read-only access |
| 410 | # Allowed chars for API_KEY and API_KEY_READ_ONLY: a-z, A-Z, 0-9, - |
| 411 | # You can define API_KEY and/or API_KEY_READ_ONLY |
| 412 | |
| 413 | #API_KEY= |
| 414 | #API_KEY_READ_ONLY= |
| 415 | #API_ALLOW_FROM=172.22.1.1,127.0.0.1 |
| 416 | |
| 417 | # mail_home is ~/Maildir |
| 418 | MAILDIR_SUB=Maildir |
| 419 | |
| 420 | # SOGo session timeout in minutes |
| 421 | SOGO_EXPIRE_SESSION=480 |
| 422 | |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 423 | # SOGo URL encryption key (exactly 16 characters, limited to A–Z, a–z, 0–9) |
| 424 | # This key is used to encrypt email addresses within SOGo URLs |
| 425 | SOGO_URL_ENCRYPTION_KEY=$(LC_ALL=C </dev/urandom tr -dc A-Za-z0-9 2>/dev/null | head -c 16) |
| 426 | |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 427 | # DOVECOT_MASTER_USER and DOVECOT_MASTER_PASS must both be provided. No special chars. |
| 428 | # Empty by default to auto-generate master user and password on start. |
| 429 | # User expands to DOVECOT_MASTER_USER@mailcow.local |
| 430 | # LEAVE EMPTY IF UNSURE |
| 431 | DOVECOT_MASTER_USER= |
| 432 | # LEAVE EMPTY IF UNSURE |
| 433 | DOVECOT_MASTER_PASS= |
| 434 | |
| Matthias Andreas Benkard | 3c18a08 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 435 | # WebAuthn device manufacturer verification |
| 436 | # After setting WEBAUTHN_ONLY_TRUSTED_VENDORS=y only devices from trusted manufacturers are allowed |
| 437 | # root certificates can be placed for validation under mailcow-dockerized/data/web/inc/lib/WebAuthn/rootCertificates |
| 438 | WEBAUTHN_ONLY_TRUSTED_VENDORS=n |
| 439 | |
| Matthias Andreas Benkard | d63fe56 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 440 | # Spamhaus Data Query Service Key |
| 441 | # Optional: Leave empty for none |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 442 | # Enter your key here if you are using a blocked ASN (OVH, AWS, Cloudflare e.g) for the unregistered Spamhaus Blocklist. |
| Matthias Andreas Benkard | d63fe56 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 443 | # If empty, it will completely disable Spamhaus blocklists if it detects that you are running on a server using a blocked AS. |
| 444 | # Otherwise it will work normally. |
| 445 | SPAMHAUS_DQS_KEY= |
| 446 | |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 447 | # IPv6 Controller Section |
| 448 | # This variable controls the usage of IPv6 within mailcow. |
| 449 | # Can either be true or false | Defaults to true |
| 450 | # WARNING: MAKE SURE TO PROPERLY CONFIGURE IPv6 ON YOUR HOST FIRST BEFORE ENABLING THIS AS FAULTY CONFIGURATIONS CAN LEAD TO OPEN RELAYS! |
| 451 | # A COMPLETE DOCKER STACK REBUILD (compose down && compose up -d) IS NEEDED TO APPLY THIS. |
| 452 | ENABLE_IPV6=${IPV6_BOOL} |
| 453 | |
| Matthias Andreas Benkard | 9dabdab | 2024-03-06 13:12:09 +0100 | [diff] [blame] | 454 | # Prevent netfilter from setting an iptables/nftables rule to isolate the mailcow docker network - y/n |
| 455 | # CAUTION: Disabling this may expose container ports to other neighbors on the same subnet, even if the ports are bound to localhost |
| 456 | DISABLE_NETFILTER_ISOLATION_RULE=n |
| Matthias Andreas Benkard | 4edeb9f | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 457 | EOF |
| 458 | |
| 459 | mkdir -p data/assets/ssl |
| 460 | |
| 461 | chmod 600 mailcow.conf |
| 462 | |
| 463 | # copy but don't overwrite existing certificate |
| 464 | echo "Generating snake-oil certificate..." |
| 465 | # Making Willich more popular |
| 466 | openssl req -x509 -newkey rsa:4096 -keyout data/assets/ssl-example/key.pem -out data/assets/ssl-example/cert.pem -days 365 -subj "/C=DE/ST=NRW/L=Willich/O=mailcow/OU=mailcow/CN=${MAILCOW_HOSTNAME}" -sha256 -nodes |
| 467 | echo "Copying snake-oil certificate..." |
| 468 | cp -n -d data/assets/ssl-example/*.pem data/assets/ssl/ |
| Matthias Andreas Benkard | 3c18a08 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 469 | |
| 470 | # Set app_info.inc.php |
| Matthias Andreas Benkard | d63fe56 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 471 | case ${git_branch} in |
| 472 | master) |
| 473 | mailcow_git_version=$(git describe --tags `git rev-list --tags --max-count=1`) |
| 474 | ;; |
| 475 | nightly) |
| 476 | mailcow_git_version=$(git rev-parse --short $(git rev-parse @{upstream})) |
| 477 | mailcow_last_git_version="" |
| 478 | ;; |
| Matthias Andreas Benkard | 97f1202 | 2026-10-23 08:46:40 +0200 | [diff] [blame] | 479 | legacy) |
| 480 | mailcow_git_version=$(git rev-parse --short $(git rev-parse @{upstream})) |
| 481 | mailcow_last_git_version="" |
| 482 | ;; |
| Matthias Andreas Benkard | d63fe56 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 483 | *) |
| 484 | mailcow_git_version=$(git rev-parse --short HEAD) |
| 485 | mailcow_last_git_version="" |
| 486 | ;; |
| 487 | esac |
| 488 | # if [ ${git_branch} == "master" ]; then |
| 489 | # mailcow_git_version=$(git describe --tags `git rev-list --tags --max-count=1`) |
| 490 | # elif [ ${git_branch} == "nightly" ]; then |
| 491 | # mailcow_git_version=$(git rev-parse --short $(git rev-parse @{upstream})) |
| 492 | # mailcow_last_git_version="" |
| 493 | # else |
| 494 | # mailcow_git_version=$(git rev-parse --short HEAD) |
| 495 | # mailcow_last_git_version="" |
| 496 | # fi |
| Matthias Andreas Benkard | 3c18a08 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 497 | |
| Matthias Andreas Benkard | d63fe56 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 498 | if [[ $SKIP_BRANCH != "y" ]]; then |
| Matthias Andreas Benkard | 3c18a08 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 499 | mailcow_git_commit=$(git rev-parse origin/${git_branch}) |
| 500 | mailcow_git_commit_date=$(git log -1 --format=%ci @{upstream} ) |
| Matthias Andreas Benkard | d63fe56 | 2023-11-18 13:18:30 +0100 | [diff] [blame] | 501 | else |
| 502 | mailcow_git_commit=$(git rev-parse ${git_branch}) |
| 503 | mailcow_git_commit_date=$(git log -1 --format=%ci @{upstream} ) |
| 504 | git_branch=$(git rev-parse --abbrev-ref HEAD) |
| 505 | fi |
| Matthias Andreas Benkard | 3c18a08 | 2022-12-27 17:32:58 +0100 | [diff] [blame] | 506 | |
| 507 | if [ $? -eq 0 ]; then |
| 508 | echo '<?php' > data/web/inc/app_info.inc.php |
| 509 | echo ' $MAILCOW_GIT_VERSION="'$mailcow_git_version'";' >> data/web/inc/app_info.inc.php |
| 510 | echo ' $MAILCOW_LAST_GIT_VERSION="";' >> data/web/inc/app_info.inc.php |
| 511 | echo ' $MAILCOW_GIT_OWNER="mailcow";' >> data/web/inc/app_info.inc.php |
| 512 | echo ' $MAILCOW_GIT_REPO="mailcow-dockerized";' >> data/web/inc/app_info.inc.php |
| 513 | echo ' $MAILCOW_GIT_URL="https://github.com/mailcow/mailcow-dockerized";' >> data/web/inc/app_info.inc.php |
| 514 | echo ' $MAILCOW_GIT_COMMIT="'$mailcow_git_commit'";' >> data/web/inc/app_info.inc.php |
| 515 | echo ' $MAILCOW_GIT_COMMIT_DATE="'$mailcow_git_commit_date'";' >> data/web/inc/app_info.inc.php |
| 516 | echo ' $MAILCOW_BRANCH="'$git_branch'";' >> data/web/inc/app_info.inc.php |
| 517 | echo ' $MAILCOW_UPDATEDAT='$(date +%s)';' >> data/web/inc/app_info.inc.php |
| 518 | echo '?>' >> data/web/inc/app_info.inc.php |
| 519 | else |
| 520 | echo '<?php' > data/web/inc/app_info.inc.php |
| 521 | echo ' $MAILCOW_GIT_VERSION="'$mailcow_git_version'";' >> data/web/inc/app_info.inc.php |
| 522 | echo ' $MAILCOW_LAST_GIT_VERSION="";' >> data/web/inc/app_info.inc.php |
| 523 | echo ' $MAILCOW_GIT_OWNER="mailcow";' >> data/web/inc/app_info.inc.php |
| 524 | echo ' $MAILCOW_GIT_REPO="mailcow-dockerized";' >> data/web/inc/app_info.inc.php |
| 525 | echo ' $MAILCOW_GIT_URL="https://github.com/mailcow/mailcow-dockerized";' >> data/web/inc/app_info.inc.php |
| 526 | echo ' $MAILCOW_GIT_COMMIT="";' >> data/web/inc/app_info.inc.php |
| 527 | echo ' $MAILCOW_GIT_COMMIT_DATE="";' >> data/web/inc/app_info.inc.php |
| 528 | echo ' $MAILCOW_BRANCH="'$git_branch'";' >> data/web/inc/app_info.inc.php |
| 529 | echo ' $MAILCOW_UPDATEDAT='$(date +%s)';' >> data/web/inc/app_info.inc.php |
| 530 | echo '?>' >> data/web/inc/app_info.inc.php |
| 531 | echo -e "\e[33mCannot determine current git repository version...\e[0m" |
| 532 | fi |