generate_config.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. # Misc configuration
  40. # ------------------------------
  41. # You should leave that alone
  42. # Can also be 11.22.33.44:25 or 0.0.0.0:465 etc. for specific bindings
  43. HTTPS_PORT=443
  44. SMTP_PORT=25
  45. SMTPS_PORT=465
  46. SUBMISSION_PORT=587
  47. IMAP_PORT=143
  48. IMAPS_PORT=993
  49. POP_PORT=110
  50. POPS_PORT=995
  51. SIEVE_PORT=4190
  52. # Your timezone
  53. TZ=${TZ}
  54. EOF