generate_config.sh 3.7 KB

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