generate_config.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. [[ -a /etc/timezone ]] && TZ=$(cat /etc/timezone)
  17. if [ -z "$TZ" ]; then
  18. read -p "Timezone: " -ei "Europe/Berlin" TZ
  19. else
  20. read -p "Timezone: " -ei ${TZ} TZ
  21. fi
  22. cat << EOF > mailcow.conf
  23. # ------------------------------
  24. # mailcow web ui configuration
  25. # ------------------------------
  26. # example.org is _not_ a valid hostname, use a fqdn here.
  27. # Default admin user is "admin"
  28. # Default password is "moohoo"
  29. MAILCOW_HOSTNAME=${MAILCOW_HOSTNAME}
  30. # ------------------------------
  31. # SQL database configuration
  32. # ------------------------------
  33. DBNAME=mailcow
  34. DBUSER=mailcow
  35. # Please use long, random alphanumeric strings (A-Za-z0-9)
  36. DBPASS=$(</dev/urandom tr -dc A-Za-z0-9 | head -c 28)
  37. DBROOT=$(</dev/urandom tr -dc A-Za-z0-9 | head -c 28)
  38. # ------------------------------
  39. # HTTP/S Bindings
  40. # ------------------------------
  41. # You should use HTTPS, but in case of SSL offloaded reverse proxies:
  42. HTTP_PORT=80
  43. HTTP_BIND=0.0.0.0
  44. HTTPS_PORT=443
  45. HTTPS_BIND=0.0.0.0
  46. # ------------------------------
  47. # Other bindings
  48. # ------------------------------
  49. # You should leave that alone
  50. # Format: 11.22.33.44:25 or 0.0.0.0:465 etc.
  51. # Do _not_ use IP:PORT in HTTPS_BIND or HTTPS_PORT
  52. SMTP_PORT=25
  53. SMTPS_PORT=465
  54. SUBMISSION_PORT=587
  55. IMAP_PORT=143
  56. IMAPS_PORT=993
  57. POP_PORT=110
  58. POPS_PORT=995
  59. SIEVE_PORT=4190
  60. # Your timezone
  61. TZ=${TZ}
  62. # Fixed project name
  63. COMPOSE_PROJECT_NAME=mailcow-dockerized
  64. # Additional SAN for the certificate
  65. ADDITIONAL_SAN=
  66. EOF
  67. # copy but don't overwrite existing certificate
  68. cp -n data/assets/ssl-example/*.pem data/assets/ssl/