diff --git a/evoacme/files/hooks/commit b/evoacme/files/hooks/commit new file mode 100644 index 00000000..86381dce --- /dev/null +++ b/evoacme/files/hooks/commit @@ -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 diff --git a/evoacme/tasks/main.yml b/evoacme/tasks/main.yml index 08bb980a..09edb86c 100644 --- a/evoacme/tasks/main.yml +++ b/evoacme/tasks/main.yml @@ -17,6 +17,7 @@ - reload_nginx - reload_dovecot - reload_postfix + - commit - include: conf.yml