blob: 420854eac46da98a0fdb2fd5871f5da1eb702888 [file] [log] [blame]
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +01001#!/usr/bin/env bash
2
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +02003# 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
5SCRIPT_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
8if [ ! -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
12fi
13
14# Verify the .env symlink points to a mailcow.conf file
15env_target="$(readlink -f "${PWD}/.env" 2>/dev/null || true)"
16if [ -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
22fi
23
24# Load mailcow Generic Scripts
25source _modules/scripts/core.sh
26source _modules/scripts/ipv6_controller.sh
27
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +010028set -o pipefail
29
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +020030get_installed_tools
31get_docker_version
32
33if [[ $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 Benkard4edeb9f2021-01-02 15:32:21 +010037 exit 1
38fi
39
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +020040detect_bad_asn
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +010041
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
43if [[ ${1} == "--dev" || ${1} == "-d" ]]; then
44 SKIP_BRANCH=y
45else
46 SKIP_BRANCH=n
47fi
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +010048
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +010049if [ -f mailcow.conf ]; then
Matthias Andreas Benkard8f915942021-08-16 10:57:25 +020050 read -r -p "A config file exists and will be overwritten, are you sure you want to continue? [y/N] " response
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +010051 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
60fi
61
62echo "Press enter to confirm the detected value '[value]' where applicable or enter a custom value."
63while [ -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 Benkardd63fe562023-11-18 13:18:30 +010066 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 Benkard4edeb9f2021-01-02 15:32:21 +010084 fi
85done
86
87if [ -a /etc/timezone ]; then
88 DETECTED_TZ=$(cat /etc/timezone)
89elif [ -a /etc/localtime ]; then
90 DETECTED_TZ=$(readlink /etc/localtime|sed -n 's|^.*zoneinfo/||p')
91fi
92
93while [ -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
100done
101
102MEM_TOTAL=$(awk '/MemTotal/ {print $2}' /proc/meminfo)
103
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +0200104if [ -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 Benkard4edeb9f2021-01-02 15:32:21 +0100115 ;;
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +0200116 esac
117 else
118 SKIP_CLAMD=n
119 fi
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100120fi
121
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100122if [[ ${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 Benkard97f12022026-10-23 08:46:40 +0200128 echo "- legacy branch (supported until February 2026) | deprecated, security updates only [3]"
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100129 sleep 1
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +0100130
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100131 while [ -z "${MAILCOW_BRANCH}" ]; do
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +0200132 read -r -p "Choose the Branch with it's number [1/2/3] " branch
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100133 case $branch in
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +0200134 [3])
135 MAILCOW_BRANCH="legacy"
136 ;;
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100137 [2])
138 MAILCOW_BRANCH="nightly"
139 ;;
140 *)
141 MAILCOW_BRANCH="master"
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +0100142 ;;
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100143 esac
144 done
145
146 git fetch --all
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +0200147 git checkout -f "$MAILCOW_BRANCH"
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100148
149elif [[ ${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
154else
155 echo -e "\033[31mCould not determine branch input..."
156 echo -e "\033[31mExiting."
157 exit 1
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +0200158fi
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +0100159
160if [ ! -z "${MAILCOW_BRANCH}" ]; then
161 git_branch=${MAILCOW_BRANCH}
162fi
163
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +0200164configure_ipv6
165
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100166[ ! -f ./data/conf/rspamd/override.d/worker-controller-password.inc ] && echo '# Placeholder' > ./data/conf/rspamd/override.d/worker-controller-password.inc
167
168cat << 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 Benkard4edeb9f2021-01-02 15:32:21 +0100175MAILCOW_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 Benkardd63fe562023-11-18 13:18:30 +0100179# see https://docs.mailcow.email/models/model-passwd/
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100180MAILCOW_PASS_SCHEME=BLF-CRYPT
181
182# ------------------------------
183# SQL database configuration
184# ------------------------------
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100185DBNAME=mailcow
186DBUSER=mailcow
187
188# Please use long, random alphanumeric strings (A-Za-z0-9)
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +0200189DBPASS=${MAILCOW_DBPASS:-$(LC_ALL=C </dev/urandom tr -dc A-Za-z0-9 2> /dev/null | head -c 28)}
190DBROOT=${MAILCOW_DBROOT:-$(LC_ALL=C </dev/urandom tr -dc A-Za-z0-9 2> /dev/null | head -c 28)}
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100191
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +0200192# ------------------------------
193# REDIS configuration
194# ------------------------------
195REDISPASS=${MAILCOW_REDISPASS:-$(LC_ALL=C </dev/urandom tr -dc A-Za-z0-9 2> /dev/null | head -c 28)}
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100196
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 Benkard97f12022026-10-23 08:46:40 +0200205# IMPORTANT: Do not use port 8081, 9081, 9082 or 65510!
Matthias Andreas Benkard8f915942021-08-16 10:57:25 +0200206# Example: HTTP_BIND=1.2.3.4
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +0100207# For IPv4 leave it as it is: HTTP_BIND= & HTTPS_PORT=
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100208# For IPv6 see https://docs.mailcow.email/post_installation/firststeps-ip_bindings/
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100209HTTP_PORT=80
Matthias Andreas Benkard8f915942021-08-16 10:57:25 +0200210HTTP_BIND=
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100211
212HTTPS_PORT=443
Matthias Andreas Benkard8f915942021-08-16 10:57:25 +0200213HTTPS_BIND=
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100214
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +0200215# Redirect HTTP connections to HTTPS - y/n
216HTTP_REDIRECT=y
217
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100218# ------------------------------
219# Other bindings
220# ------------------------------
221# You should leave that alone
Matthias Andreas Benkard8f915942021-08-16 10:57:25 +0200222# Format: 11.22.33.44:25 or 12.34.56.78:465 etc.
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100223SMTP_PORT=25
224SMTPS_PORT=465
225SUBMISSION_PORT=587
226IMAP_PORT=143
227IMAPS_PORT=993
228POP_PORT=110
229POPS_PORT=995
230SIEVE_PORT=4190
231DOVEADM_PORT=127.0.0.1:19991
232SQL_PORT=127.0.0.1:13306
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100233REDIS_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 Benkardd63fe562023-11-18 13:18:30 +0100237# Use the column named 'TZ identifier' + pay attention for the column named 'Notes'
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100238TZ=${MAILCOW_TZ}
239
240# Fixed project name
241# Please use lowercase letters only
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100242COMPOSE_PROJECT_NAME=mailcowdockerized
243
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +0100244# Used Docker Compose version
245# Switch here between native (compose plugin) and standalone
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +0200246# For more information take a look at the mailcow docs regarding the configuration options.
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +0100247# Normally this should be untouched but if you decided to use either of those you can switch it manually here.
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100248# Please be aware that at least one of those variants should be installed on your machine or mailcow will fail.
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +0100249DOCKER_COMPOSE_VERSION=${COMPOSE_VERSION}
250
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100251# 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 Benkard97f12022026-10-23 08:46:40 +0200253# This should probably only be activated on mail hosts, that are used exclusively by one organisation.
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100254# Otherwise a user might share data with too many other users.
255ACL_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 Benkard4edeb9f2021-01-02 15:32:21 +0100261MAILDIR_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 Benkard3c18a082022-12-27 17:32:58 +0100268# This will expand the certificate to "imap.example.com", "smtp.example.com", "imap.example.net", "smtp.example.net"
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100269# 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 Benkard4edeb9f2021-01-02 15:32:21 +0100275ADDITIONAL_SAN=
276
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +0200277# 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.
282AUTODISCOVER_SAN=y
283
Matthias Andreas Benkard8f915942021-08-16 10:57:25 +0200284# 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 Benkard8f915942021-08-16 10:57:25 +0200291ADDITIONAL_SERVER_NAMES=
292
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100293# Skip running ACME (acme-mailcow, Let's Encrypt certs) - y/n
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100294SKIP_LETS_ENCRYPT=n
295
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +0200296# Enable DNS-01 challenge for ACME (acme-mailcow) - y/n
297# This requires you to set ACME_DNS_PROVIDER and ACME_ACCOUNT_EMAIL below
298ACME_DNS_CHALLENGE=n
299ACME_DNS_PROVIDER=dns_xxx
300ACME_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 Benkard4edeb9f2021-01-02 15:32:21 +0100312# this will allow adding more than 100 domains, but some email clients will not be able to connect with alternative hostnames
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100313# see https://doc.dovecot.org/admin_manual/ssl/sni_support
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100314ENABLE_SSL_SNI=n
315
316# Skip IPv4 check in ACME container - y/n
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100317SKIP_IP_CHECK=n
318
319# Skip HTTP verification in ACME container - y/n
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100320SKIP_HTTP_VERIFICATION=n
321
Matthias Andreas Benkard9dabdab2024-03-06 13:12:09 +0100322# Skip Unbound (DNS Resolver) Healthchecks (NOT Recommended!) - y/n
Matthias Andreas Benkard9dabdab2024-03-06 13:12:09 +0100323SKIP_UNBOUND_HEALTHCHECK=n
324
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100325# Skip ClamAV (clamd-mailcow) anti-virus (Rspamd will auto-detect a missing ClamAV container) - y/n
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100326SKIP_CLAMD=${SKIP_CLAMD}
327
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +0200328# Skip Olefy (olefy-mailcow) anti-virus for Office documents (Rspamd will auto-detect a missing Olefy container) - y/n
329SKIP_OLEFY=n
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100330
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +0200331# Skip SOGo: Will disable SOGo integration and therefore webmail, DAV protocols and ActiveSync support (experimental, unsupported, not fully implemented) - y/n
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100332SKIP_SOGO=n
333
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +0200334# 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.
336SKIP_FTS=n
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100337
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +0200338# 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!
341FTS_HEAP=128
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100342
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +0200343# 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
346FTS_PROCS=1
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100347
348# Allow admins to log into SOGo as email user (without any password)
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100349ALLOW_ADMIN_EMAIL_LOGIN=n
350
351# Enable watchdog (watchdog-mailcow) to restart unhealthy containers
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100352USE_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 Benkard4edeb9f2021-01-02 15:32:21 +0100360#WATCHDOG_NOTIFY_EMAIL=a@example.com,b@example.com,c@example.com
361#WATCHDOG_NOTIFY_EMAIL=
362
Matthias Andreas Benkard9dabdab2024-03-06 13:12:09 +0100363# 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 Benkard4edeb9f2021-01-02 15:32:21 +0100370# Notify about banned IP (includes whois lookup)
371WATCHDOG_NOTIFY_BAN=n
372
Matthias Andreas Benkard9dabdab2024-03-06 13:12:09 +0100373# Send a notification when the watchdog is started.
374WATCHDOG_NOTIFY_START=y
375
Matthias Andreas Benkard8f915942021-08-16 10:57:25 +0200376# Subject for watchdog mails. Defaults to "Watchdog ALERT" followed by the error message.
377#WATCHDOG_SUBJECT=
378
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100379# 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.
384WATCHDOG_EXTERNAL_CHECKS=n
385
Matthias Andreas Benkardb4b5cc12021-12-28 18:02:04 +0100386# Enable watchdog verbose logging
387WATCHDOG_VERBOSE=n
388
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100389# Max log lines per service to keep in Redis logs
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100390LOG_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 Benkard4edeb9f2021-01-02 15:32:21 +0100394IPV4_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 Benkard4edeb9f2021-01-02 15:32:21 +0100398IPV6_NETWORK=fd4d:6169:6c63:6f77::/64
399
400# Use this IPv4 for outgoing connections (SNAT)
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100401#SNAT_TO_SOURCE=
402
403# Use this IPv6 for outgoing connections (SNAT)
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100404#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
418MAILDIR_SUB=Maildir
419
420# SOGo session timeout in minutes
421SOGO_EXPIRE_SESSION=480
422
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +0200423# 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
425SOGO_URL_ENCRYPTION_KEY=$(LC_ALL=C </dev/urandom tr -dc A-Za-z0-9 2>/dev/null | head -c 16)
426
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100427# 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
431DOVECOT_MASTER_USER=
432# LEAVE EMPTY IF UNSURE
433DOVECOT_MASTER_PASS=
434
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +0100435# 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
438WEBAUTHN_ONLY_TRUSTED_VENDORS=n
439
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100440# Spamhaus Data Query Service Key
441# Optional: Leave empty for none
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +0200442# Enter your key here if you are using a blocked ASN (OVH, AWS, Cloudflare e.g) for the unregistered Spamhaus Blocklist.
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100443# 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.
445SPAMHAUS_DQS_KEY=
446
Matthias Andreas Benkard97f12022026-10-23 08:46:40 +0200447# 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.
452ENABLE_IPV6=${IPV6_BOOL}
453
Matthias Andreas Benkard9dabdab2024-03-06 13:12:09 +0100454# 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
456DISABLE_NETFILTER_ISOLATION_RULE=n
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100457EOF
458
459mkdir -p data/assets/ssl
460
461chmod 600 mailcow.conf
462
463# copy but don't overwrite existing certificate
464echo "Generating snake-oil certificate..."
465# Making Willich more popular
466openssl 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
467echo "Copying snake-oil certificate..."
468cp -n -d data/assets/ssl-example/*.pem data/assets/ssl/
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +0100469
470# Set app_info.inc.php
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100471case ${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 Benkard97f12022026-10-23 08:46:40 +0200479 legacy)
480 mailcow_git_version=$(git rev-parse --short $(git rev-parse @{upstream}))
481 mailcow_last_git_version=""
482 ;;
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100483 *)
484 mailcow_git_version=$(git rev-parse --short HEAD)
485 mailcow_last_git_version=""
486 ;;
487esac
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 Benkard3c18a082022-12-27 17:32:58 +0100497
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100498if [[ $SKIP_BRANCH != "y" ]]; then
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +0100499mailcow_git_commit=$(git rev-parse origin/${git_branch})
500mailcow_git_commit_date=$(git log -1 --format=%ci @{upstream} )
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100501else
502mailcow_git_commit=$(git rev-parse ${git_branch})
503mailcow_git_commit_date=$(git log -1 --format=%ci @{upstream} )
504git_branch=$(git rev-parse --abbrev-ref HEAD)
505fi
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +0100506
507if [ $? -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
519else
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"
532fi