generate_config.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #!/bin/bash
  2. +#exit on error and pipefail
  3. +set -o errexit
  4. +set -o pipefail
  5. if grep --help 2>&1 | head -n 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 | head -n 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. cat << EOF > mailcow.conf
  38. # ------------------------------
  39. # mailcow web ui configuration
  40. # ------------------------------
  41. # example.org is _not_ a valid hostname, use a fqdn here.
  42. # Default admin user is "admin"
  43. # Default password is "moohoo"
  44. MAILCOW_HOSTNAME=${MAILCOW_HOSTNAME}
  45. # ------------------------------
  46. # SQL database configuration
  47. # ------------------------------
  48. DBNAME=mailcow
  49. DBUSER=mailcow
  50. # Please use long, random alphanumeric strings (A-Za-z0-9)
  51. DBPASS=$(</dev/urandom tr -dc A-Za-z0-9 | head -c 28)
  52. DBROOT=$(</dev/urandom tr -dc A-Za-z0-9 | head -c 28)
  53. # ------------------------------
  54. # HTTP/S Bindings
  55. # ------------------------------
  56. # You should use HTTPS, but in case of SSL offloaded reverse proxies:
  57. HTTP_PORT=80
  58. HTTP_BIND=0.0.0.0
  59. HTTPS_PORT=443
  60. HTTPS_BIND=0.0.0.0
  61. # ------------------------------
  62. # Other bindings
  63. # ------------------------------
  64. # You should leave that alone
  65. # Format: 11.22.33.44:25 or 0.0.0.0:465 etc.
  66. # Do _not_ use IP:PORT in HTTP(S)_BIND or HTTP(S)_PORT
  67. SMTP_PORT=25
  68. SMTPS_PORT=465
  69. SUBMISSION_PORT=587
  70. IMAP_PORT=143
  71. IMAPS_PORT=993
  72. POP_PORT=110
  73. POPS_PORT=995
  74. SIEVE_PORT=4190
  75. DOVEADM_PORT=127.0.0.1:19991
  76. # Your timezone
  77. TZ=${TZ}
  78. # Fixed project name
  79. COMPOSE_PROJECT_NAME=mailcow-dockerized
  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 Fail2ban implementation (fail2ban-mailcow) - y/n
  87. SKIP_FAIL2BAN=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 fd00::/8
  99. IPV6_NETWORK=fd4d:6169:6c63:6f77::/64
  100. EOF
  101. mkdir -p data/assets/ssl
  102. # copy but don't overwrite existing certificate
  103. cp -n data/assets/ssl-example/*.pem data/assets/ssl/