evoacme: add a renewal hook to commit changes in /etc/.git

This commit is contained in:
Jérémy Lecour 2019-03-07 00:19:43 +01:00
parent aebd46e4d7
commit 8279092037
2 changed files with 19 additions and 0 deletions

View file

@ -0,0 +1,18 @@
#!/bin/sh
git_bin=$(command -v git)
letsencrypt_dir=/etc/letsencrypt
export GIT_DIR="/etc/.git"
export GIT_WORK_TREE="/etc"
if test -x "${git_bin}" && test -d "${GIT_DIR}" && test -d "${GIT_WORK_TREE}"; then
changed_lines=$(${git_bin} status --porcelain -- ${letsencrypt_dir} | wc -l | tr -d ' ')
if [ "${changed_lines}" != "0" ]; then
${git_bin} add --all ${letsencrypt_dir}
message="[letsencrypt] certificates renewal (${RENEWED_DOMAINS})"
${git_bin} commit --message "${message}" --quiet
else
echo "Weird, nothing has changed but the hook has been executed for '${RENEWED_DOMAINS}'"
fi
fi

View file

@ -17,6 +17,7 @@
- reload_nginx
- reload_dovecot
- reload_postfix
- commit
- include: conf.yml