You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.2 KiB

  1. #!/usr/bin/env sh
  2. #Here is a script to deploy cert to mailcow.
  3. #returns 0 means success, otherwise error.
  4. ######## Public functions #####################
  5. #domain keyfile certfile cafile fullchain
  6. mailcow_deploy() {
  7. _cdomain="$1"
  8. _ckey="$2"
  9. _ccert="$3"
  10. _cca="$4"
  11. _cfullchain="$5"
  12. _debug _cdomain "$_cdomain"
  13. _debug _ckey "$_ckey"
  14. _debug _ccert "$_ccert"
  15. _debug _cca "$_cca"
  16. _debug _cfullchain "$_cfullchain"
  17. _ssl_path="${DEPLOY_MAILCOW_PATH}/data/assets/ssl/"
  18. if [ ! -d "$_ssl_path"; ] then
  19. _err "Cannot find mailcow ssl path: $_ssl_path"
  20. return 1
  21. fi
  22. _info "Copying key and cert"
  23. _real_key="$_ssl_path/key.pem"
  24. if ! cat "$_ckey" >"$_real_key"; then
  25. _err "Error: write key file to: $_real_key"
  26. return 1
  27. fi
  28. _real_fullchain="$_ssl_path/cert.pem"
  29. if ! cat "$_cfullchain" >"$_real_fullchain"; then
  30. _err "Error: write cert file to: $_real_fullchain"
  31. return 1
  32. fi
  33. DEFAULT_MAILCOW_RELOAD="docker-compose restart postfix-mailcow dovecot-mailcow nginx-mailcow"
  34. _reload="${DEPLOY_MAILCOW_RELOAD:-$DEFAULT_MAILCOW_RELOAD}"
  35. _info "Run reload: $_reload"
  36. if eval "$_reload"; then
  37. _info "Reload success!"
  38. fi
  39. return 0
  40. }