generate_config.sh 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. while [ -z "${MAILCOW_HOSTNAME}" ]; do
  23. read -p "Hostname (FQDN): " -ei "mx.example.org" MAILCOW_HOSTNAME
  24. DOTS=${MAILCOW_HOSTNAME//[^.]};
  25. if [ ${#DOTS} -lt 2 ]; then
  26. echo "${MAILCOW_HOSTNAME} is not a FQDN"
  27. MAILCOW_HOSTNAME=
  28. fi
  29. done
  30. if [[ -a /etc/timezone ]]; then
  31. TZ=$(cat /etc/timezone)
  32. elif [[ -a /etc/localtime ]]; then
  33. TZ=$(readlink /etc/localtime|sed -n 's|^.*zoneinfo/||p')
  34. fi
  35. if [ -z "$TZ" ]; then
  36. read -p "Timezone: " -ei "Europe/Berlin" TZ
  37. else
  38. read -p "Timezone: " -ei ${TZ} TZ
  39. fi
  40. [[ ! -f ./data/conf/rspamd/override.d/worker-controller-password.inc ]] && echo '# Placeholder' > ./data/conf/rspamd/override.d/worker-controller-password.inc
  41. cat << EOF > mailcow.conf
  42. # ------------------------------
  43. # mailcow web ui configuration
  44. # ------------------------------
  45. # example.org is _not_ a valid hostname, use a fqdn here.
  46. # Default admin user is "admin"
  47. # Default password is "moohoo"
  48. MAILCOW_HOSTNAME=${MAILCOW_HOSTNAME}
  49. # ------------------------------
  50. # SQL database configuration
  51. # ------------------------------
  52. DBNAME=mailcow
  53. DBUSER=mailcow
  54. # Please use long, random alphanumeric strings (A-Za-z0-9)
  55. DBPASS=$(</dev/urandom tr -dc A-Za-z0-9 | head -c 28)
  56. DBROOT=$(</dev/urandom tr -dc A-Za-z0-9 | head -c 28)
  57. # ------------------------------
  58. # HTTP/S Bindings
  59. # ------------------------------
  60. # You should use HTTPS, but in case of SSL offloaded reverse proxies:
  61. HTTP_PORT=80
  62. HTTP_BIND=0.0.0.0
  63. HTTPS_PORT=443
  64. HTTPS_BIND=0.0.0.0
  65. # ------------------------------
  66. # Other bindings
  67. # ------------------------------
  68. # You should leave that alone
  69. # Format: 11.22.33.44:25 or 0.0.0.0:465 etc.
  70. # Do _not_ use IP:PORT in HTTP(S)_BIND or HTTP(S)_PORT
  71. SMTP_PORT=25
  72. SMTPS_PORT=465
  73. SUBMISSION_PORT=587
  74. IMAP_PORT=143
  75. IMAPS_PORT=993
  76. POP_PORT=110
  77. POPS_PORT=995
  78. SIEVE_PORT=4190
  79. DOVEADM_PORT=127.0.0.1:19991
  80. SQL_PORT=127.0.0.1:13306
  81. # Your timezone
  82. TZ=${TZ}
  83. # Fixed project name
  84. COMPOSE_PROJECT_NAME=mailcowdockerized
  85. # Additional SAN for the certificate
  86. ADDITIONAL_SAN=
  87. # Skip running ACME (acme-mailcow, Let's Encrypt certs) - y/n
  88. SKIP_LETS_ENCRYPT=n
  89. # Skip IPv4 check in ACME container - y/n
  90. SKIP_IP_CHECK=n
  91. # Skip ClamAV (clamd-mailcow) anti-virus (Rspamd will auto-detect a missing ClamAV container) - y/n
  92. SKIP_CLAMD=n
  93. # Enable watchdog (watchdog-mailcow) to restart unhealthy containers (experimental)
  94. USE_WATCHDOG=n
  95. # Send notifications by mail (no DKIM signature, sent from watchdog@MAILCOW_HOSTNAME)
  96. #WATCHDOG_NOTIFY_EMAIL=
  97. # Max log lines per service to keep in Redis logs
  98. LOG_LINES=9999
  99. # Internal IPv4 /24 subnet, format n.n.n. (expands to n.n.n.0/24)
  100. IPV4_NETWORK=172.22.1
  101. # Internal IPv6 subnet in fc00::/7
  102. IPV6_NETWORK=fd4d:6169:6c63:6f77::/64
  103. # Use this IPv4 for outgoing connections (SNAT)
  104. #SNAT_TO_SOURCE=
  105. # Use this IPv6 for outgoing connections (SNAT)
  106. #SNAT6_TO_SOURCE=
  107. # Disable IPv6
  108. # mailcow-network will still be created as IPv6 enabled, all containers will be created
  109. # without IPv6 support.
  110. # Use 1 for disabled, 0 for enabled
  111. SYSCTL_IPV6_DISABLED=0
  112. # Create or override API key for web uI
  113. # You _must_ define API_ALLOW_FROM, which is a comma separated list of IPs
  114. #API_KEY=
  115. #API_ALLOW_FROM=127.0.0.1,1.2.3.4
  116. EOF
  117. mkdir -p data/assets/ssl
  118. # copy but don't overwrite existing certificate
  119. cp -n data/assets/ssl-example/*.pem data/assets/ssl/