]> git.proxmox.com Git - mirror_acme.sh.git/blame - deploy/mailcow.sh
Merge pull request #4441 from plummer86/bugfix/_wget_out_fix
[mirror_acme.sh.git] / deploy / mailcow.sh
CommitLineData
307336cf
VB
1#!/usr/bin/env sh
2
3#Here is a script to deploy cert to mailcow.
4
5#returns 0 means success, otherwise error.
6
7######## Public functions #####################
8
9#domain keyfile certfile cafile fullchain
10mailcow_deploy() {
11 _cdomain="$1"
12 _ckey="$2"
13 _ccert="$3"
14 _cca="$4"
15 _cfullchain="$5"
16
17 _debug _cdomain "$_cdomain"
18 _debug _ckey "$_ckey"
19 _debug _ccert "$_ccert"
20 _debug _cca "$_cca"
21 _debug _cfullchain "$_cfullchain"
22
201673ca 23 _getdeployconf DEPLOY_MAILCOW_PATH
24 _getdeployconf DEPLOY_MAILCOW_RELOAD
d643a2ff 25
201673ca 26 _debug DEPLOY_MAILCOW_PATH "$DEPLOY_MAILCOW_PATH"
27 _debug DEPLOY_MAILCOW_RELOAD "$DEPLOY_MAILCOW_RELOAD"
28
29 if [ -z "$DEPLOY_MAILCOW_PATH" ]; then
d6041661
VB
30 _err "Mailcow path is not found, please define DEPLOY_MAILCOW_PATH."
31 return 1
d643a2ff
VB
32 fi
33
201673ca 34 _savedeployconf DEPLOY_MAILCOW_PATH "$DEPLOY_MAILCOW_PATH"
201673ca 35 [ -n "$DEPLOY_MAILCOW_RELOAD" ] && _savedeployconf DEPLOY_MAILCOW_RELOAD "$DEPLOY_MAILCOW_RELOAD"
36
08ae8cc3 37 _ssl_path="$DEPLOY_MAILCOW_PATH"
201673ca 38 if [ -f "$DEPLOY_MAILCOW_PATH/generate_config.sh" ]; then
39 _ssl_path="$DEPLOY_MAILCOW_PATH/data/assets/ssl/"
2bc62797
CB
40 fi
41
d643a2ff 42 if [ ! -d "$_ssl_path" ]; then
d6041661
VB
43 _err "Cannot find mailcow ssl path: $_ssl_path"
44 return 1
307336cf
VB
45 fi
46
47 _info "Copying key and cert"
2cbf1259 48 _real_key="$_ssl_path/key.pem"
307336cf
VB
49 if ! cat "$_ckey" >"$_real_key"; then
50 _err "Error: write key file to: $_real_key"
51 return 1
52 fi
53
2cbf1259 54 _real_fullchain="$_ssl_path/cert.pem"
307336cf
VB
55 if ! cat "$_cfullchain" >"$_real_fullchain"; then
56 _err "Error: write cert file to: $_real_fullchain"
57 return 1
58 fi
59
41801a60 60 DEFAULT_MAILCOW_RELOAD="docker restart \$(docker ps --quiet --filter name=nginx-mailcow --filter name=dovecot-mailcow --filter name=postfix-mailcow)"
307336cf
VB
61 _reload="${DEPLOY_MAILCOW_RELOAD:-$DEFAULT_MAILCOW_RELOAD}"
62
63 _info "Run reload: $_reload"
64 if eval "$_reload"; then
65 _info "Reload success!"
66 fi
67 return 0
68
69}