generate_config.sh 2.6 KB

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