generate_config.sh 4.0 KB

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