2020-06-01 10:29:16 +00:00
|
|
|
deploy_cert() {<%text>
|
|
|
|
local DOMAIN="${1}" KEYFILE="${2}" CERTFILE="${3}" FULLCHAINFILE="${4}" CHAINFILE="${5}" TIMESTAMP="${6}"</%text>
|
|
|
|
% for service, config in node.metadata.get('letsencrypt', {}).get('concat_and_deploy', {}).items():
|
2021-01-10 09:48:19 +00:00
|
|
|
|
|
|
|
# concat_and_deploy ${service}
|
2020-06-01 10:29:16 +00:00
|
|
|
if [ "$DOMAIN" = "${config['match_domain']}" ]; then
|
|
|
|
cat $KEYFILE > ${config['target']}
|
|
|
|
cat $FULLCHAINFILE >> ${config['target']}
|
|
|
|
% if 'chown' in config:
|
|
|
|
chown ${config['chown']} ${config['target']}
|
|
|
|
% endif
|
|
|
|
% if 'chmod' in config:
|
|
|
|
chmod ${config['chmod']} ${config['target']}
|
|
|
|
% endif
|
|
|
|
% if 'commands' in config:
|
|
|
|
% for command in config['commands']:
|
|
|
|
${command}
|
|
|
|
% endfor
|
|
|
|
% endif
|
|
|
|
fi
|
|
|
|
% endfor
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
exit_hook() {<%text>
|
|
|
|
local ERROR="${1:-}"</%text>
|
|
|
|
|
|
|
|
% for service in sorted(node.metadata.get('letsencrypt', {}).get('reload_after', set())):
|
|
|
|
systemctl reload-or-restart ${service}
|
|
|
|
% endfor
|
|
|
|
}
|
|
|
|
|
|
|
|
<%text>
|
|
|
|
HANDLER="$1"; shift
|
|
|
|
if [[ "${HANDLER}" =~ ^(deploy_cert|exit_hook)$ ]]; then
|
2021-02-17 09:56:18 +00:00
|
|
|
"$HANDLER" "$@"
|
2020-06-01 10:29:16 +00:00
|
|
|
fi</%text>
|