generate_config.sh 3.6 KB

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