generate_config.sh 3.2 KB

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