blob: f25309ead6ef274cc3d1385391049ef95d4d2c05 [file] [log] [blame]
Matthias Andreas Benkardb382b102021-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 Benkard12a57352021-12-28 18:02:04 +010015 exit 1
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010016 fi
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010017fi
18
Matthias Andreas Benkard1ba53812022-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 Benkardb382b102021-01-02 15:32:21 +010023
Matthias Andreas Benkardd1f5b682023-11-18 13:18:30 +010024for bin in openssl curl docker git awk sha1sum grep cut; do
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010025 if [[ -z $(which ${bin}) ]]; then echo "Cannot find ${bin}, exiting..."; exit 1; fi
26done
27
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010028if docker compose > /dev/null 2>&1; then
29 if docker compose version --short | grep "^2." > /dev/null 2>&1; then
30 COMPOSE_VERSION=native
31 echo -e "\e[31mFound Docker Compose Plugin (native).\e[0m"
32 echo -e "\e[31mSetting the DOCKER_COMPOSE_VERSION Variable to native\e[0m"
33 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 Benkardd1f5b682023-11-18 13:18:30 +010037 echo -e "\e[31mPlease update/install it manually regarding to this doc site: https://docs.mailcow.email/i_u_m/i_u_m_install/\e[0m"
Matthias Andreas Benkard1ba53812022-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
44 echo -e "\e[31mFound Docker Compose Standalone.\e[0m"
45 echo -e "\e[31mSetting the DOCKER_COMPOSE_VERSION Variable to standalone\e[0m"
46 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 Benkardd1f5b682023-11-18 13:18:30 +010050 echo -e "\e[31mPlease update/install manually regarding to this doc site: https://docs.mailcow.email/i_u_m/i_u_m_install/\e[0m"
Matthias Andreas Benkard1ba53812022-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 Benkardd1f5b682023-11-18 13:18:30 +010057 echo -e "\e[31mPlease install it regarding to this doc site: https://docs.mailcow.email/i_u_m/i_u_m_install/\e[0m"
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010058 exit 1
59fi
Matthias Andreas Benkardd1f5b682023-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 Benkard1ba53812022-12-27 17:32:58 +010094
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010095if [ -f mailcow.conf ]; then
Matthias Andreas Benkard7b2a3a12021-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 Benkardb382b102021-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 Benkardd1f5b682023-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 Benkardb382b102021-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 Benkardd1f5b682023-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 Benkard1ba53812022-12-27 17:32:58 +0100193
Matthias Andreas Benkardd1f5b682023-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 Benkard1ba53812022-12-27 17:32:58 +0100202 ;;
Matthias Andreas Benkardd1f5b682023-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 Benkard1ba53812022-12-27 17:32:58 +0100219
220if [ ! -z "${MAILCOW_BRANCH}" ]; then
221 git_branch=${MAILCOW_BRANCH}
222fi
223
Matthias Andreas Benkardb382b102021-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 Benkardd1f5b682023-11-18 13:18:30 +0100238# see https://docs.mailcow.email/models/model-passwd/
Matthias Andreas Benkardb382b102021-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 Benkardd1f5b682023-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 Benkardb382b102021-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 Benkard7b2a3a12021-08-16 10:57:25 +0200262# Example: HTTP_BIND=1.2.3.4
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +0100263# For IPv4 leave it as it is: HTTP_BIND= & HTTPS_PORT=
Matthias Andreas Benkardd1f5b682023-11-18 13:18:30 +0100264# For IPv6 see https://docs.mailcow.email/post_installation/firststeps-ip_bindings/
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +0100265
266HTTP_PORT=80
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +0200267HTTP_BIND=
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +0100268
269HTTPS_PORT=443
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +0200270HTTPS_BIND=
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +0100271
272# ------------------------------
273# Other bindings
274# ------------------------------
275# You should leave that alone
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +0200276# Format: 11.22.33.44:25 or 12.34.56.78:465 etc.
Matthias Andreas Benkardb382b102021-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 Benkardd1f5b682023-11-18 13:18:30 +0100293# Use the column named 'TZ identifier' + pay attention for the column named 'Notes'
Matthias Andreas Benkardb382b102021-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 Benkard1ba53812022-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 Benkardd1f5b682023-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 Benkard1ba53812022-12-27 17:32:58 +0100307
308DOCKER_COMPOSE_VERSION=${COMPOSE_VERSION}
309
Matthias Andreas Benkardb382b102021-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 Benkard1ba53812022-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 Benkardb382b102021-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 Benkard7b2a3a12021-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 Benkardb382b102021-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 Benkardd1f5b682023-11-18 13:18:30 +0100355# see https://doc.dovecot.org/admin_manual/ssl/sni_support
Matthias Andreas Benkardb382b102021-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
366# Skip ClamAV (clamd-mailcow) anti-virus (Rspamd will auto-detect a missing ClamAV container) - y/n
367
368SKIP_CLAMD=${SKIP_CLAMD}
369
370# Skip SOGo: Will disable SOGo integration and therefore webmail, DAV protocols and ActiveSync support (experimental, unsupported, not fully implemented) - y/n
371
372SKIP_SOGO=n
373
374# Skip Solr on low-memory systems or if you do not want to store a readable index of your mails in solr-vol-1.
375
376SKIP_SOLR=${SKIP_SOLR}
377
378# Solr heap size in MB, there is no recommendation, please see Solr docs.
379# Solr is a prone to run OOM and should be monitored. Unmonitored Solr setups are not recommended.
380
381SOLR_HEAP=1024
382
383# Allow admins to log into SOGo as email user (without any password)
384
385ALLOW_ADMIN_EMAIL_LOGIN=n
386
387# Enable watchdog (watchdog-mailcow) to restart unhealthy containers
388
389USE_WATCHDOG=y
390
391# Send watchdog notifications by mail (sent from watchdog@MAILCOW_HOSTNAME)
392# CAUTION:
393# 1. You should use external recipients
394# 2. Mails are sent unsigned (no DKIM)
395# 3. If you use DMARC, create a separate DMARC policy ("v=DMARC1; p=none;" in _dmarc.MAILCOW_HOSTNAME)
396# Multiple rcpts allowed, NO quotation marks, NO spaces
397
398#WATCHDOG_NOTIFY_EMAIL=a@example.com,b@example.com,c@example.com
399#WATCHDOG_NOTIFY_EMAIL=
400
401# Notify about banned IP (includes whois lookup)
402WATCHDOG_NOTIFY_BAN=n
403
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +0200404# Subject for watchdog mails. Defaults to "Watchdog ALERT" followed by the error message.
405#WATCHDOG_SUBJECT=
406
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +0100407# Checks if mailcow is an open relay. Requires a SAL. More checks will follow.
408# https://www.servercow.de/mailcow?lang=en
409# https://www.servercow.de/mailcow?lang=de
410# No data is collected. Opt-in and anonymous.
411# Will only work with unmodified mailcow setups.
412WATCHDOG_EXTERNAL_CHECKS=n
413
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +0100414# Enable watchdog verbose logging
415WATCHDOG_VERBOSE=n
416
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +0100417# Max log lines per service to keep in Redis logs
418
419LOG_LINES=9999
420
421# Internal IPv4 /24 subnet, format n.n.n (expands to n.n.n.0/24)
422# Use private IPv4 addresses only, see https://en.wikipedia.org/wiki/Private_network#Private_IPv4_addresses
423
424IPV4_NETWORK=172.22.1
425
426# Internal IPv6 subnet in fc00::/7
427# Use private IPv6 addresses only, see https://en.wikipedia.org/wiki/Private_network#Private_IPv6_addresses
428
429IPV6_NETWORK=fd4d:6169:6c63:6f77::/64
430
431# Use this IPv4 for outgoing connections (SNAT)
432
433#SNAT_TO_SOURCE=
434
435# Use this IPv6 for outgoing connections (SNAT)
436
437#SNAT6_TO_SOURCE=
438
439# Create or override an API key for the web UI
440# You _must_ define API_ALLOW_FROM, which is a comma separated list of IPs
441# An API key defined as API_KEY has read-write access
442# An API key defined as API_KEY_READ_ONLY has read-only access
443# Allowed chars for API_KEY and API_KEY_READ_ONLY: a-z, A-Z, 0-9, -
444# You can define API_KEY and/or API_KEY_READ_ONLY
445
446#API_KEY=
447#API_KEY_READ_ONLY=
448#API_ALLOW_FROM=172.22.1.1,127.0.0.1
449
450# mail_home is ~/Maildir
451MAILDIR_SUB=Maildir
452
453# SOGo session timeout in minutes
454SOGO_EXPIRE_SESSION=480
455
456# DOVECOT_MASTER_USER and DOVECOT_MASTER_PASS must both be provided. No special chars.
457# Empty by default to auto-generate master user and password on start.
458# User expands to DOVECOT_MASTER_USER@mailcow.local
459# LEAVE EMPTY IF UNSURE
460DOVECOT_MASTER_USER=
461# LEAVE EMPTY IF UNSURE
462DOVECOT_MASTER_PASS=
463
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +0200464# Let's Encrypt registration contact information
465# Optional: Leave empty for none
466# This value is only used on first order!
467# Setting it at a later point will require the following steps:
Matthias Andreas Benkardd1f5b682023-11-18 13:18:30 +0100468# https://docs.mailcow.email/troubleshooting/debug-reset_tls/
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +0200469ACME_CONTACT=
470
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +0100471# WebAuthn device manufacturer verification
472# After setting WEBAUTHN_ONLY_TRUSTED_VENDORS=y only devices from trusted manufacturers are allowed
473# root certificates can be placed for validation under mailcow-dockerized/data/web/inc/lib/WebAuthn/rootCertificates
474WEBAUTHN_ONLY_TRUSTED_VENDORS=n
475
Matthias Andreas Benkardd1f5b682023-11-18 13:18:30 +0100476# Spamhaus Data Query Service Key
477# Optional: Leave empty for none
478# Enter your key here if you are using a blocked ASN (OVH, AWS, Cloudflare e.g) for the unregistered Spamhaus Blocklist.
479# If empty, it will completely disable Spamhaus blocklists if it detects that you are running on a server using a blocked AS.
480# Otherwise it will work normally.
481SPAMHAUS_DQS_KEY=
482
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +0100483EOF
484
485mkdir -p data/assets/ssl
486
487chmod 600 mailcow.conf
488
489# copy but don't overwrite existing certificate
490echo "Generating snake-oil certificate..."
491# Making Willich more popular
492openssl 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
493echo "Copying snake-oil certificate..."
494cp -n -d data/assets/ssl-example/*.pem data/assets/ssl/
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +0100495
496# Set app_info.inc.php
Matthias Andreas Benkardd1f5b682023-11-18 13:18:30 +0100497case ${git_branch} in
498 master)
499 mailcow_git_version=$(git describe --tags `git rev-list --tags --max-count=1`)
500 ;;
501 nightly)
502 mailcow_git_version=$(git rev-parse --short $(git rev-parse @{upstream}))
503 mailcow_last_git_version=""
504 ;;
505 *)
506 mailcow_git_version=$(git rev-parse --short HEAD)
507 mailcow_last_git_version=""
508 ;;
509esac
510# if [ ${git_branch} == "master" ]; then
511# mailcow_git_version=$(git describe --tags `git rev-list --tags --max-count=1`)
512# elif [ ${git_branch} == "nightly" ]; then
513# mailcow_git_version=$(git rev-parse --short $(git rev-parse @{upstream}))
514# mailcow_last_git_version=""
515# else
516# mailcow_git_version=$(git rev-parse --short HEAD)
517# mailcow_last_git_version=""
518# fi
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +0100519
Matthias Andreas Benkardd1f5b682023-11-18 13:18:30 +0100520if [[ $SKIP_BRANCH != "y" ]]; then
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +0100521mailcow_git_commit=$(git rev-parse origin/${git_branch})
522mailcow_git_commit_date=$(git log -1 --format=%ci @{upstream} )
Matthias Andreas Benkardd1f5b682023-11-18 13:18:30 +0100523else
524mailcow_git_commit=$(git rev-parse ${git_branch})
525mailcow_git_commit_date=$(git log -1 --format=%ci @{upstream} )
526git_branch=$(git rev-parse --abbrev-ref HEAD)
527fi
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +0100528
529if [ $? -eq 0 ]; then
530 echo '<?php' > data/web/inc/app_info.inc.php
531 echo ' $MAILCOW_GIT_VERSION="'$mailcow_git_version'";' >> data/web/inc/app_info.inc.php
532 echo ' $MAILCOW_LAST_GIT_VERSION="";' >> data/web/inc/app_info.inc.php
533 echo ' $MAILCOW_GIT_OWNER="mailcow";' >> data/web/inc/app_info.inc.php
534 echo ' $MAILCOW_GIT_REPO="mailcow-dockerized";' >> data/web/inc/app_info.inc.php
535 echo ' $MAILCOW_GIT_URL="https://github.com/mailcow/mailcow-dockerized";' >> data/web/inc/app_info.inc.php
536 echo ' $MAILCOW_GIT_COMMIT="'$mailcow_git_commit'";' >> data/web/inc/app_info.inc.php
537 echo ' $MAILCOW_GIT_COMMIT_DATE="'$mailcow_git_commit_date'";' >> data/web/inc/app_info.inc.php
538 echo ' $MAILCOW_BRANCH="'$git_branch'";' >> data/web/inc/app_info.inc.php
539 echo ' $MAILCOW_UPDATEDAT='$(date +%s)';' >> data/web/inc/app_info.inc.php
540 echo '?>' >> data/web/inc/app_info.inc.php
541else
542 echo '<?php' > data/web/inc/app_info.inc.php
543 echo ' $MAILCOW_GIT_VERSION="'$mailcow_git_version'";' >> data/web/inc/app_info.inc.php
544 echo ' $MAILCOW_LAST_GIT_VERSION="";' >> data/web/inc/app_info.inc.php
545 echo ' $MAILCOW_GIT_OWNER="mailcow";' >> data/web/inc/app_info.inc.php
546 echo ' $MAILCOW_GIT_REPO="mailcow-dockerized";' >> data/web/inc/app_info.inc.php
547 echo ' $MAILCOW_GIT_URL="https://github.com/mailcow/mailcow-dockerized";' >> data/web/inc/app_info.inc.php
548 echo ' $MAILCOW_GIT_COMMIT="";' >> data/web/inc/app_info.inc.php
549 echo ' $MAILCOW_GIT_COMMIT_DATE="";' >> data/web/inc/app_info.inc.php
550 echo ' $MAILCOW_BRANCH="'$git_branch'";' >> data/web/inc/app_info.inc.php
551 echo ' $MAILCOW_UPDATEDAT='$(date +%s)';' >> data/web/inc/app_info.inc.php
552 echo '?>' >> data/web/inc/app_info.inc.php
553 echo -e "\e[33mCannot determine current git repository version...\e[0m"
554fi
Matthias Andreas Benkardd1f5b682023-11-18 13:18:30 +0100555
556detect_bad_asn