generate_config.sh 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #!/bin/bash
  2. set -o pipefail
  3. if grep --help 2>&1 | grep -q -i "busybox"; then
  4. echo "BusybBox grep detected, please install gnu grep, \"apk add --no-cache --upgrade grep\""
  5. exit 1
  6. fi
  7. if cp --help 2>&1 | grep -q -i "busybox"; then
  8. echo "BusybBox cp detected, please install coreutils, \"apk add --no-cache --upgrade coreutils\""
  9. exit 1
  10. fi
  11. if [ -f mailcow.conf ]; then
  12. read -r -p "A config file exists and will be overwritten, are you sure you want to contine? [y/N] " response
  13. case $response in
  14. [yY][eE][sS]|[yY])
  15. mv mailcow.conf mailcow.conf_backup
  16. ;;
  17. *)
  18. exit 1
  19. ;;
  20. esac
  21. fi
  22. echo "Press enter to confirm the detected value '[value]' where applicable or enter a custom value."
  23. while [ -z "${MAILCOW_HOSTNAME}" ]; do
  24. read -p "Hostname (FQDN): " -e MAILCOW_HOSTNAME
  25. DOTS=${MAILCOW_HOSTNAME//[^.]};
  26. if [ ${#DOTS} -lt 2 ] && [ ! -z ${MAILCOW_HOSTNAME} ]; then
  27. echo "${MAILCOW_HOSTNAME} is not a FQDN"
  28. MAILCOW_HOSTNAME=
  29. fi
  30. done
  31. if [ -a /etc/timezone ]; then
  32. DETECTED_TZ=$(cat /etc/timezone)
  33. elif [ -a /etc/localtime ]; then
  34. DETECTED_TZ=$(readlink /etc/localtime|sed -n 's|^.*zoneinfo/||p')
  35. fi
  36. while [ -z "${MAILCOW_TZ}" ]; do
  37. if [ -z "${DETECTED_TZ}" ]; then
  38. read -p "Timezone: " -e MAILCOW_TZ
  39. else
  40. read -p "Timezone [${DETECTED_TZ}]: " -e MAILCOW_TZ
  41. [ -z "${MAILCOW_TZ}" ] && MAILCOW_TZ=${DETECTED_TZ}
  42. fi
  43. done
  44. [ ! -f ./data/conf/rspamd/override.d/worker-controller-password.inc ] && echo '# Placeholder' > ./data/conf/rspamd/override.d/worker-controller-password.inc
  45. cat << EOF > mailcow.conf
  46. # ------------------------------
  47. # mailcow web ui configuration
  48. # ------------------------------
  49. # example.org is _not_ a valid hostname, use a fqdn here.
  50. # Default admin user is "admin"
  51. # Default password is "moohoo"
  52. MAILCOW_HOSTNAME=${MAILCOW_HOSTNAME}
  53. # ------------------------------
  54. # SQL database configuration
  55. # ------------------------------
  56. DBNAME=mailcow
  57. DBUSER=mailcow
  58. # Please use long, random alphanumeric strings (A-Za-z0-9)
  59. DBPASS=$(LC_ALL=C </dev/urandom tr -dc A-Za-z0-9 | head -c 28)
  60. DBROOT=$(LC_ALL=C </dev/urandom tr -dc A-Za-z0-9 | head -c 28)
  61. # ------------------------------
  62. # HTTP/S Bindings
  63. # ------------------------------
  64. # You should use HTTPS, but in case of SSL offloaded reverse proxies:
  65. HTTP_PORT=80
  66. HTTP_BIND=0.0.0.0
  67. HTTPS_PORT=443
  68. HTTPS_BIND=0.0.0.0
  69. # ------------------------------
  70. # Other bindings
  71. # ------------------------------
  72. # You should leave that alone
  73. # Format: 11.22.33.44:25 or 0.0.0.0:465 etc.
  74. # Do _not_ use IP:PORT in HTTP(S)_BIND or HTTP(S)_PORT
  75. SMTP_PORT=25
  76. SMTPS_PORT=465
  77. SUBMISSION_PORT=587
  78. IMAP_PORT=143
  79. IMAPS_PORT=993
  80. POP_PORT=110
  81. POPS_PORT=995
  82. SIEVE_PORT=4190
  83. DOVEADM_PORT=127.0.0.1:19991
  84. SQL_PORT=127.0.0.1:13306
  85. # Your timezone
  86. TZ=${MAILCOW_TZ}
  87. # Fixed project name
  88. COMPOSE_PROJECT_NAME=mailcowdockerized
  89. # Garbage collector cleanup
  90. # Deleted domains and mailboxes are moved to /var/vmail/_garbage/timestamp_sanitizedstring
  91. # How long should objects remain in the garbage until they are being deleted? (value in minutes)
  92. # Check interval is hourly
  93. MAILDIR_GC_TIME=1440
  94. # Additional SAN for the certificate
  95. ADDITIONAL_SAN=
  96. # Skip running ACME (acme-mailcow, Let's Encrypt certs) - y/n
  97. SKIP_LETS_ENCRYPT=n
  98. # Skip IPv4 check in ACME container - y/n
  99. SKIP_IP_CHECK=n
  100. # Skip ClamAV (clamd-mailcow) anti-virus (Rspamd will auto-detect a missing ClamAV container) - y/n
  101. SKIP_CLAMD=n
  102. # Enable watchdog (watchdog-mailcow) to restart unhealthy containers (experimental)
  103. USE_WATCHDOG=n
  104. # Send notifications by mail (no DKIM signature, sent from watchdog@MAILCOW_HOSTNAME)
  105. #WATCHDOG_NOTIFY_EMAIL=
  106. # Max log lines per service to keep in Redis logs
  107. LOG_LINES=9999
  108. # Internal IPv4 /24 subnet, format n.n.n. (expands to n.n.n.0/24)
  109. IPV4_NETWORK=172.22.1
  110. # Internal IPv6 subnet in fc00::/7
  111. IPV6_NETWORK=fd4d:6169:6c63:6f77::/64
  112. # Use this IPv4 for outgoing connections (SNAT)
  113. #SNAT_TO_SOURCE=
  114. # Use this IPv6 for outgoing connections (SNAT)
  115. #SNAT6_TO_SOURCE=
  116. # Disable IPv6
  117. # mailcow-network will still be created as IPv6 enabled, all containers will be created
  118. # without IPv6 support.
  119. # Use 1 for disabled, 0 for enabled
  120. SYSCTL_IPV6_DISABLED=0
  121. # Create or override API key for web uI
  122. # You _must_ define API_ALLOW_FROM, which is a comma separated list of IPs
  123. # API_KEY allowed chars: a-z, A-Z, 0-9, -
  124. #API_KEY=
  125. #API_ALLOW_FROM=127.0.0.1,1.2.3.4
  126. EOF
  127. mkdir -p data/assets/ssl
  128. # copy but don't overwrite existing certificate
  129. cp -n data/assets/ssl-example/*.pem data/assets/ssl/