blob: 05d9ee2f10d5ca36dfe537f5ca1abcdfef043616 [file] [log] [blame]
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +01001#!/usr/bin/env bash
2
3set -o pipefail
4
5if [[ "$(uname -r)" =~ ^4\.15\.0-60 ]]; then
6 echo "DO NOT RUN mailcow ON THIS UBUNTU KERNEL!";
7 echo "Please update to 5.x or use another distribution."
8 exit 1
9fi
10
11if [[ "$(uname -r)" =~ ^4\.4\. ]]; then
12 if grep -q Ubuntu <<< $(uname -a); then
13 echo "DO NOT RUN mailcow ON THIS UBUNTU KERNEL!";
14 echo "Please update to linux-generic-hwe-16.04 by running \"apt-get install --install-recommends linux-generic-hwe-16.04\""
Matthias Andreas Benkardb4b5cc12021-12-28 18:02:04 +010015 exit 1
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +010016 fi
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +010017fi
18
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +010019if 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
20# This will also cover sort
21if 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
22if 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
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +010023
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +010024for bin in openssl curl docker git awk sha1sum grep cut; do
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +010025 if [[ -z $(which ${bin}) ]]; then echo "Cannot find ${bin}, exiting..."; exit 1; fi
26done
27
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +010028if docker compose > /dev/null 2>&1; then
Matthias Andreas Benkard9dabdab2024-03-06 13:12:09 +010029 if docker compose version --short | grep -e "^2." -e "^v2." > /dev/null 2>&1; then
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +010030 COMPOSE_VERSION=native
Matthias Andreas Benkard9dabdab2024-03-06 13:12:09 +010031 echo -e "\e[33mFound Docker Compose Plugin (native).\e[0m"
32 echo -e "\e[33mSetting the DOCKER_COMPOSE_VERSION Variable to native\e[0m"
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +010033 sleep 2
34 echo -e "\e[33mNotice: You´ll have to update this Compose Version via your Package Manager manually!\e[0m"
35 else
36 echo -e "\e[31mCannot find Docker Compose with a Version Higher than 2.X.X.\e[0m"
Matthias Andreas Benkard9dabdab2024-03-06 13:12:09 +010037 echo -e "\e[31mPlease update/install it manually regarding to this doc site: https://docs.mailcow.email/install/\e[0m"
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +010038 exit 1
39 fi
40elif docker-compose > /dev/null 2>&1; then
41 if ! [[ $(alias docker-compose 2> /dev/null) ]] ; then
42 if docker-compose version --short | grep "^2." > /dev/null 2>&1; then
43 COMPOSE_VERSION=standalone
Matthias Andreas Benkard9dabdab2024-03-06 13:12:09 +010044 echo -e "\e[33mFound Docker Compose Standalone.\e[0m"
45 echo -e "\e[33mSetting the DOCKER_COMPOSE_VERSION Variable to standalone\e[0m"
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +010046 sleep 2
47 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"
48 else
49 echo -e "\e[31mCannot find Docker Compose with a Version Higher than 2.X.X.\e[0m"
Matthias Andreas Benkard9dabdab2024-03-06 13:12:09 +010050 echo -e "\e[31mPlease update/install manually regarding to this doc site: https://docs.mailcow.email/install/\e[0m"
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +010051 exit 1
52 fi
53 fi
54
55else
56 echo -e "\e[31mCannot find Docker Compose.\e[0m"
Matthias Andreas Benkard9dabdab2024-03-06 13:12:09 +010057 echo -e "\e[31mPlease install it regarding to this doc site: https://docs.mailcow.email/install/\e[0m"
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +010058 exit 1
59fi
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +010060
61detect_bad_asn() {
62 echo -e "\e[33mDetecting if your IP is listed on Spamhaus Bad ASN List...\e[0m"
63 response=$(curl --connect-timeout 15 --max-time 30 -s -o /dev/null -w "%{http_code}" "https://asn-check.mailcow.email")
64 if [ "$response" -eq 503 ]; then
65 if [ -z "$SPAMHAUS_DQS_KEY" ]; then
66 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"
67 echo -e "\e[33mmailcow did not detected a value for the variable SPAMHAUS_DQS_KEY inside mailcow.conf!\e[0m"
68 sleep 2
69 echo ""
70 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"
71 echo -e "\e[33mOnce done, enter your DQS API key in mailcow.conf and mailcow will do the rest for you!\e[0m"
72 echo ""
73 sleep 2
74
75 else
76 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"
77 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"
78 fi
79 elif [ "$response" -eq 200 ]; then
80 echo -e "\e[33mCheck completed! Your IP is \e[32mclean\e[0m"
81 elif [ "$response" -eq 429 ]; then
82 echo -e "\e[33mCheck completed! \e[31mYour IP seems to be rate limited on the ASN Check service... please try again later!\e[0m"
83 else
84 echo -e "\e[31mCheck failed! \e[0mMaybe a DNS or Network problem?\e[0m"
85 fi
86}
87
88### 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
89if [[ ${1} == "--dev" || ${1} == "-d" ]]; then
90 SKIP_BRANCH=y
91else
92 SKIP_BRANCH=n
93fi
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +010094
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +010095if [ -f mailcow.conf ]; then
Matthias Andreas Benkard8f915942021-08-16 10:57:25 +020096 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 +010097 case $response in
98 [yY][eE][sS]|[yY])
99 mv mailcow.conf mailcow.conf_backup
100 chmod 600 mailcow.conf_backup
101 ;;
102 *)
103 exit 1
104 ;;
105 esac
106fi
107
108echo "Press enter to confirm the detected value '[value]' where applicable or enter a custom value."
109while [ -z "${MAILCOW_HOSTNAME}" ]; do
110 read -p "Mail server hostname (FQDN) - this is not your mail domain, but your mail servers hostname: " -e MAILCOW_HOSTNAME
111 DOTS=${MAILCOW_HOSTNAME//[^.]};
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100112 if [ ${#DOTS} -lt 1 ]; then
113 echo -e "\e[31mMAILCOW_HOSTNAME (${MAILCOW_HOSTNAME}) is not a FQDN!\e[0m"
114 sleep 1
115 echo "Please change it to a FQDN and redeploy the stack with docker(-)compose up -d"
116 exit 1
117 elif [[ "${MAILCOW_HOSTNAME: -1}" == "." ]]; then
118 echo "MAILCOW_HOSTNAME (${MAILCOW_HOSTNAME}) is ending with a dot. This is not a valid FQDN!"
119 exit 1
120 elif [ ${#DOTS} -eq 1 ]; then
121 echo -e "\e[33mMAILCOW_HOSTNAME (${MAILCOW_HOSTNAME}) does not contain a Subdomain. This is not fully tested and may cause issues.\e[0m"
122 echo "Find more information about why this message exists here: https://github.com/mailcow/mailcow-dockerized/issues/1572"
123 read -r -p "Do you want to proceed anyway? [y/N] " response
124 if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
125 echo "OK. Procceding."
126 else
127 echo "OK. Exiting."
128 exit 1
129 fi
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100130 fi
131done
132
133if [ -a /etc/timezone ]; then
134 DETECTED_TZ=$(cat /etc/timezone)
135elif [ -a /etc/localtime ]; then
136 DETECTED_TZ=$(readlink /etc/localtime|sed -n 's|^.*zoneinfo/||p')
137fi
138
139while [ -z "${MAILCOW_TZ}" ]; do
140 if [ -z "${DETECTED_TZ}" ]; then
141 read -p "Timezone: " -e MAILCOW_TZ
142 else
143 read -p "Timezone [${DETECTED_TZ}]: " -e MAILCOW_TZ
144 [ -z "${MAILCOW_TZ}" ] && MAILCOW_TZ=${DETECTED_TZ}
145 fi
146done
147
148MEM_TOTAL=$(awk '/MemTotal/ {print $2}' /proc/meminfo)
149
150if [ ${MEM_TOTAL} -le "2621440" ]; then
151 echo "Installed memory is <= 2.5 GiB. It is recommended to disable ClamAV to prevent out-of-memory situations."
152 echo "ClamAV can be re-enabled by setting SKIP_CLAMD=n in mailcow.conf."
153 read -r -p "Do you want to disable ClamAV now? [Y/n] " response
154 case $response in
155 [nN][oO]|[nN])
156 SKIP_CLAMD=n
157 ;;
158 *)
159 SKIP_CLAMD=y
160 ;;
161 esac
162else
163 SKIP_CLAMD=n
164fi
165
166if [ ${MEM_TOTAL} -le "2097152" ]; then
167 echo "Disabling Solr on low-memory system."
168 SKIP_SOLR=y
169elif [ ${MEM_TOTAL} -le "3670016" ]; then
170 echo "Installed memory is <= 3.5 GiB. It is recommended to disable Solr to prevent out-of-memory situations."
171 echo "Solr is a prone to run OOM and should be monitored. The default Solr heap size is 1024 MiB and should be set in mailcow.conf according to your expected load."
172 echo "Solr can be re-enabled by setting SKIP_SOLR=n in mailcow.conf but will refuse to start with less than 2 GB total memory."
173 read -r -p "Do you want to disable Solr now? [Y/n] " response
174 case $response in
175 [nN][oO]|[nN])
176 SKIP_SOLR=n
177 ;;
178 *)
179 SKIP_SOLR=y
180 ;;
181 esac
182else
183 SKIP_SOLR=n
184fi
185
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100186if [[ ${SKIP_BRANCH} != y ]]; then
187 echo "Which branch of mailcow do you want to use?"
188 echo ""
189 echo "Available Branches:"
190 echo "- master branch (stable updates) | default, recommended [1]"
191 echo "- nightly branch (unstable updates, testing) | not-production ready [2]"
192 sleep 1
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +0100193
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100194 while [ -z "${MAILCOW_BRANCH}" ]; do
195 read -r -p "Choose the Branch with it´s number [1/2] " branch
196 case $branch in
197 [2])
198 MAILCOW_BRANCH="nightly"
199 ;;
200 *)
201 MAILCOW_BRANCH="master"
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +0100202 ;;
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100203 esac
204 done
205
206 git fetch --all
207 git checkout -f $MAILCOW_BRANCH
208
209elif [[ ${SKIP_BRANCH} == y ]]; then
210 echo -e "\033[33mEnabled Dev Mode.\033[0m"
211 echo -e "\033[33mNot checking out a different branch!\033[0m"
212 MAILCOW_BRANCH=$(git rev-parse --short $(git rev-parse @{upstream}))
213
214else
215 echo -e "\033[31mCould not determine branch input..."
216 echo -e "\033[31mExiting."
217 exit 1
218fi
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +0100219
220if [ ! -z "${MAILCOW_BRANCH}" ]; then
221 git_branch=${MAILCOW_BRANCH}
222fi
223
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100224[ ! -f ./data/conf/rspamd/override.d/worker-controller-password.inc ] && echo '# Placeholder' > ./data/conf/rspamd/override.d/worker-controller-password.inc
225
226cat << EOF > mailcow.conf
227# ------------------------------
228# mailcow web ui configuration
229# ------------------------------
230# example.org is _not_ a valid hostname, use a fqdn here.
231# Default admin user is "admin"
232# Default password is "moohoo"
233
234MAILCOW_HOSTNAME=${MAILCOW_HOSTNAME}
235
236# Password hash algorithm
237# Only certain password hash algorithm are supported. For a fully list of supported schemes,
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100238# see https://docs.mailcow.email/models/model-passwd/
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100239MAILCOW_PASS_SCHEME=BLF-CRYPT
240
241# ------------------------------
242# SQL database configuration
243# ------------------------------
244
245DBNAME=mailcow
246DBUSER=mailcow
247
248# Please use long, random alphanumeric strings (A-Za-z0-9)
249
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100250DBPASS=$(LC_ALL=C </dev/urandom tr -dc A-Za-z0-9 2> /dev/null | head -c 28)
251DBROOT=$(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 +0100252
253# ------------------------------
254# HTTP/S Bindings
255# ------------------------------
256
257# You should use HTTPS, but in case of SSL offloaded reverse proxies:
258# Might be important: This will also change the binding within the container.
259# If you use a proxy within Docker, point it to the ports you set below.
260# Do _not_ use IP:PORT in HTTP(S)_BIND or HTTP(S)_PORT
261# IMPORTANT: Do not use port 8081, 9081 or 65510!
Matthias Andreas Benkard8f915942021-08-16 10:57:25 +0200262# Example: HTTP_BIND=1.2.3.4
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +0100263# For IPv4 leave it as it is: HTTP_BIND= & HTTPS_PORT=
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100264# For IPv6 see https://docs.mailcow.email/post_installation/firststeps-ip_bindings/
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100265
266HTTP_PORT=80
Matthias Andreas Benkard8f915942021-08-16 10:57:25 +0200267HTTP_BIND=
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100268
269HTTPS_PORT=443
Matthias Andreas Benkard8f915942021-08-16 10:57:25 +0200270HTTPS_BIND=
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100271
272# ------------------------------
273# Other bindings
274# ------------------------------
275# You should leave that alone
Matthias Andreas Benkard8f915942021-08-16 10:57:25 +0200276# Format: 11.22.33.44:25 or 12.34.56.78:465 etc.
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100277
278SMTP_PORT=25
279SMTPS_PORT=465
280SUBMISSION_PORT=587
281IMAP_PORT=143
282IMAPS_PORT=993
283POP_PORT=110
284POPS_PORT=995
285SIEVE_PORT=4190
286DOVEADM_PORT=127.0.0.1:19991
287SQL_PORT=127.0.0.1:13306
288SOLR_PORT=127.0.0.1:18983
289REDIS_PORT=127.0.0.1:7654
290
291# Your timezone
292# 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 +0100293# Use the column named 'TZ identifier' + pay attention for the column named 'Notes'
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100294
295TZ=${MAILCOW_TZ}
296
297# Fixed project name
298# Please use lowercase letters only
299
300COMPOSE_PROJECT_NAME=mailcowdockerized
301
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +0100302# Used Docker Compose version
303# Switch here between native (compose plugin) and standalone
304# For more informations take a look at the mailcow docs regarding the configuration options.
305# 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 +0100306# 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 +0100307
308DOCKER_COMPOSE_VERSION=${COMPOSE_VERSION}
309
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100310# Set this to "allow" to enable the anyone pseudo user. Disabled by default.
311# When enabled, ACL can be created, that apply to "All authenticated users"
312# This should probably only be activated on mail hosts, that are used exclusivly by one organisation.
313# Otherwise a user might share data with too many other users.
314ACL_ANYONE=disallow
315
316# Garbage collector cleanup
317# Deleted domains and mailboxes are moved to /var/vmail/_garbage/timestamp_sanitizedstring
318# How long should objects remain in the garbage until they are being deleted? (value in minutes)
319# Check interval is hourly
320
321MAILDIR_GC_TIME=7200
322
323# Additional SAN for the certificate
324#
325# You can use wildcard records to create specific names for every domain you add to mailcow.
326# Example: Add domains "example.com" and "example.net" to mailcow, change ADDITIONAL_SAN to a value like:
327#ADDITIONAL_SAN=imap.*,smtp.*
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +0100328# 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 +0100329# plus every domain you add in the future.
330#
331# You can also just add static names...
332#ADDITIONAL_SAN=srv1.example.net
333# ...or combine wildcard and static names:
334#ADDITIONAL_SAN=imap.*,srv1.example.com
335#
336
337ADDITIONAL_SAN=
338
Matthias Andreas Benkard8f915942021-08-16 10:57:25 +0200339# Additional server names for mailcow UI
340#
341# Specify alternative addresses for the mailcow UI to respond to
342# 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.
343# If the server name does not match a known site, Nginx decides by best-guess and may redirect users to the wrong web root.
344# You can understand this as server_name directive in Nginx.
345# Comma separated list without spaces! Example: ADDITIONAL_SERVER_NAMES=a.b.c,d.e.f
346
347ADDITIONAL_SERVER_NAMES=
348
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100349# Skip running ACME (acme-mailcow, Let's Encrypt certs) - y/n
350
351SKIP_LETS_ENCRYPT=n
352
353# Create seperate certificates for all domains - y/n
354# 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 +0100355# see https://doc.dovecot.org/admin_manual/ssl/sni_support
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100356ENABLE_SSL_SNI=n
357
358# Skip IPv4 check in ACME container - y/n
359
360SKIP_IP_CHECK=n
361
362# Skip HTTP verification in ACME container - y/n
363
364SKIP_HTTP_VERIFICATION=n
365
Matthias Andreas Benkard9dabdab2024-03-06 13:12:09 +0100366# Skip Unbound (DNS Resolver) Healthchecks (NOT Recommended!) - y/n
367
368SKIP_UNBOUND_HEALTHCHECK=n
369
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100370# Skip ClamAV (clamd-mailcow) anti-virus (Rspamd will auto-detect a missing ClamAV container) - y/n
371
372SKIP_CLAMD=${SKIP_CLAMD}
373
374# Skip SOGo: Will disable SOGo integration and therefore webmail, DAV protocols and ActiveSync support (experimental, unsupported, not fully implemented) - y/n
375
376SKIP_SOGO=n
377
378# Skip Solr on low-memory systems or if you do not want to store a readable index of your mails in solr-vol-1.
379
380SKIP_SOLR=${SKIP_SOLR}
381
382# Solr heap size in MB, there is no recommendation, please see Solr docs.
383# Solr is a prone to run OOM and should be monitored. Unmonitored Solr setups are not recommended.
384
385SOLR_HEAP=1024
386
387# Allow admins to log into SOGo as email user (without any password)
388
389ALLOW_ADMIN_EMAIL_LOGIN=n
390
391# Enable watchdog (watchdog-mailcow) to restart unhealthy containers
392
393USE_WATCHDOG=y
394
395# Send watchdog notifications by mail (sent from watchdog@MAILCOW_HOSTNAME)
396# CAUTION:
397# 1. You should use external recipients
398# 2. Mails are sent unsigned (no DKIM)
399# 3. If you use DMARC, create a separate DMARC policy ("v=DMARC1; p=none;" in _dmarc.MAILCOW_HOSTNAME)
400# Multiple rcpts allowed, NO quotation marks, NO spaces
401
402#WATCHDOG_NOTIFY_EMAIL=a@example.com,b@example.com,c@example.com
403#WATCHDOG_NOTIFY_EMAIL=
404
Matthias Andreas Benkard9dabdab2024-03-06 13:12:09 +0100405# Send notifications to a webhook URL that receives a POST request with the content type "application/json".
406# You can use this to send notifications to services like Discord, Slack and others.
407#WATCHDOG_NOTIFY_WEBHOOK=https://discord.com/api/webhooks/XXXXXXXXXXXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
408# JSON body included in the webhook POST request. Needs to be in single quotes.
409# Following variables are available: SUBJECT, BODY
410#WATCHDOG_NOTIFY_WEBHOOK_BODY='{"username": "mailcow Watchdog", "content": "**${SUBJECT}**\n${BODY}"}'
411
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100412# Notify about banned IP (includes whois lookup)
413WATCHDOG_NOTIFY_BAN=n
414
Matthias Andreas Benkard9dabdab2024-03-06 13:12:09 +0100415# Send a notification when the watchdog is started.
416WATCHDOG_NOTIFY_START=y
417
Matthias Andreas Benkard8f915942021-08-16 10:57:25 +0200418# Subject for watchdog mails. Defaults to "Watchdog ALERT" followed by the error message.
419#WATCHDOG_SUBJECT=
420
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100421# Checks if mailcow is an open relay. Requires a SAL. More checks will follow.
422# https://www.servercow.de/mailcow?lang=en
423# https://www.servercow.de/mailcow?lang=de
424# No data is collected. Opt-in and anonymous.
425# Will only work with unmodified mailcow setups.
426WATCHDOG_EXTERNAL_CHECKS=n
427
Matthias Andreas Benkardb4b5cc12021-12-28 18:02:04 +0100428# Enable watchdog verbose logging
429WATCHDOG_VERBOSE=n
430
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100431# Max log lines per service to keep in Redis logs
432
433LOG_LINES=9999
434
435# Internal IPv4 /24 subnet, format n.n.n (expands to n.n.n.0/24)
436# Use private IPv4 addresses only, see https://en.wikipedia.org/wiki/Private_network#Private_IPv4_addresses
437
438IPV4_NETWORK=172.22.1
439
440# Internal IPv6 subnet in fc00::/7
441# Use private IPv6 addresses only, see https://en.wikipedia.org/wiki/Private_network#Private_IPv6_addresses
442
443IPV6_NETWORK=fd4d:6169:6c63:6f77::/64
444
445# Use this IPv4 for outgoing connections (SNAT)
446
447#SNAT_TO_SOURCE=
448
449# Use this IPv6 for outgoing connections (SNAT)
450
451#SNAT6_TO_SOURCE=
452
453# Create or override an API key for the web UI
454# You _must_ define API_ALLOW_FROM, which is a comma separated list of IPs
455# An API key defined as API_KEY has read-write access
456# An API key defined as API_KEY_READ_ONLY has read-only access
457# Allowed chars for API_KEY and API_KEY_READ_ONLY: a-z, A-Z, 0-9, -
458# You can define API_KEY and/or API_KEY_READ_ONLY
459
460#API_KEY=
461#API_KEY_READ_ONLY=
462#API_ALLOW_FROM=172.22.1.1,127.0.0.1
463
464# mail_home is ~/Maildir
465MAILDIR_SUB=Maildir
466
467# SOGo session timeout in minutes
468SOGO_EXPIRE_SESSION=480
469
470# DOVECOT_MASTER_USER and DOVECOT_MASTER_PASS must both be provided. No special chars.
471# Empty by default to auto-generate master user and password on start.
472# User expands to DOVECOT_MASTER_USER@mailcow.local
473# LEAVE EMPTY IF UNSURE
474DOVECOT_MASTER_USER=
475# LEAVE EMPTY IF UNSURE
476DOVECOT_MASTER_PASS=
477
Matthias Andreas Benkard8f915942021-08-16 10:57:25 +0200478# Let's Encrypt registration contact information
479# Optional: Leave empty for none
480# This value is only used on first order!
481# Setting it at a later point will require the following steps:
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100482# https://docs.mailcow.email/troubleshooting/debug-reset_tls/
Matthias Andreas Benkard8f915942021-08-16 10:57:25 +0200483ACME_CONTACT=
484
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +0100485# WebAuthn device manufacturer verification
486# After setting WEBAUTHN_ONLY_TRUSTED_VENDORS=y only devices from trusted manufacturers are allowed
487# root certificates can be placed for validation under mailcow-dockerized/data/web/inc/lib/WebAuthn/rootCertificates
488WEBAUTHN_ONLY_TRUSTED_VENDORS=n
489
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100490# Spamhaus Data Query Service Key
491# Optional: Leave empty for none
492# Enter your key here if you are using a blocked ASN (OVH, AWS, Cloudflare e.g) for the unregistered Spamhaus Blocklist.
493# If empty, it will completely disable Spamhaus blocklists if it detects that you are running on a server using a blocked AS.
494# Otherwise it will work normally.
495SPAMHAUS_DQS_KEY=
496
Matthias Andreas Benkard9dabdab2024-03-06 13:12:09 +0100497# Prevent netfilter from setting an iptables/nftables rule to isolate the mailcow docker network - y/n
498# CAUTION: Disabling this may expose container ports to other neighbors on the same subnet, even if the ports are bound to localhost
499DISABLE_NETFILTER_ISOLATION_RULE=n
Matthias Andreas Benkard4edeb9f2021-01-02 15:32:21 +0100500EOF
501
502mkdir -p data/assets/ssl
503
504chmod 600 mailcow.conf
505
506# copy but don't overwrite existing certificate
507echo "Generating snake-oil certificate..."
508# Making Willich more popular
509openssl 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
510echo "Copying snake-oil certificate..."
511cp -n -d data/assets/ssl-example/*.pem data/assets/ssl/
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +0100512
513# Set app_info.inc.php
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100514case ${git_branch} in
515 master)
516 mailcow_git_version=$(git describe --tags `git rev-list --tags --max-count=1`)
517 ;;
518 nightly)
519 mailcow_git_version=$(git rev-parse --short $(git rev-parse @{upstream}))
520 mailcow_last_git_version=""
521 ;;
522 *)
523 mailcow_git_version=$(git rev-parse --short HEAD)
524 mailcow_last_git_version=""
525 ;;
526esac
527# if [ ${git_branch} == "master" ]; then
528# mailcow_git_version=$(git describe --tags `git rev-list --tags --max-count=1`)
529# elif [ ${git_branch} == "nightly" ]; then
530# mailcow_git_version=$(git rev-parse --short $(git rev-parse @{upstream}))
531# mailcow_last_git_version=""
532# else
533# mailcow_git_version=$(git rev-parse --short HEAD)
534# mailcow_last_git_version=""
535# fi
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +0100536
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100537if [[ $SKIP_BRANCH != "y" ]]; then
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +0100538mailcow_git_commit=$(git rev-parse origin/${git_branch})
539mailcow_git_commit_date=$(git log -1 --format=%ci @{upstream} )
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100540else
541mailcow_git_commit=$(git rev-parse ${git_branch})
542mailcow_git_commit_date=$(git log -1 --format=%ci @{upstream} )
543git_branch=$(git rev-parse --abbrev-ref HEAD)
544fi
Matthias Andreas Benkard3c18a082022-12-27 17:32:58 +0100545
546if [ $? -eq 0 ]; then
547 echo '<?php' > data/web/inc/app_info.inc.php
548 echo ' $MAILCOW_GIT_VERSION="'$mailcow_git_version'";' >> data/web/inc/app_info.inc.php
549 echo ' $MAILCOW_LAST_GIT_VERSION="";' >> data/web/inc/app_info.inc.php
550 echo ' $MAILCOW_GIT_OWNER="mailcow";' >> data/web/inc/app_info.inc.php
551 echo ' $MAILCOW_GIT_REPO="mailcow-dockerized";' >> data/web/inc/app_info.inc.php
552 echo ' $MAILCOW_GIT_URL="https://github.com/mailcow/mailcow-dockerized";' >> data/web/inc/app_info.inc.php
553 echo ' $MAILCOW_GIT_COMMIT="'$mailcow_git_commit'";' >> data/web/inc/app_info.inc.php
554 echo ' $MAILCOW_GIT_COMMIT_DATE="'$mailcow_git_commit_date'";' >> data/web/inc/app_info.inc.php
555 echo ' $MAILCOW_BRANCH="'$git_branch'";' >> data/web/inc/app_info.inc.php
556 echo ' $MAILCOW_UPDATEDAT='$(date +%s)';' >> data/web/inc/app_info.inc.php
557 echo '?>' >> data/web/inc/app_info.inc.php
558else
559 echo '<?php' > data/web/inc/app_info.inc.php
560 echo ' $MAILCOW_GIT_VERSION="'$mailcow_git_version'";' >> data/web/inc/app_info.inc.php
561 echo ' $MAILCOW_LAST_GIT_VERSION="";' >> data/web/inc/app_info.inc.php
562 echo ' $MAILCOW_GIT_OWNER="mailcow";' >> data/web/inc/app_info.inc.php
563 echo ' $MAILCOW_GIT_REPO="mailcow-dockerized";' >> data/web/inc/app_info.inc.php
564 echo ' $MAILCOW_GIT_URL="https://github.com/mailcow/mailcow-dockerized";' >> data/web/inc/app_info.inc.php
565 echo ' $MAILCOW_GIT_COMMIT="";' >> data/web/inc/app_info.inc.php
566 echo ' $MAILCOW_GIT_COMMIT_DATE="";' >> data/web/inc/app_info.inc.php
567 echo ' $MAILCOW_BRANCH="'$git_branch'";' >> data/web/inc/app_info.inc.php
568 echo ' $MAILCOW_UPDATEDAT='$(date +%s)';' >> data/web/inc/app_info.inc.php
569 echo '?>' >> data/web/inc/app_info.inc.php
570 echo -e "\e[33mCannot determine current git repository version...\e[0m"
571fi
Matthias Andreas Benkardd63fe562023-11-18 13:18:30 +0100572
Matthias Andreas Benkard9dabdab2024-03-06 13:12:09 +0100573detect_bad_asn