From dfd9e431b444b4f1bbf39d7136837473e62ed49c Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Thu, 6 Sep 2018 10:12:26 +0200 Subject: [PATCH] handle multiple git repositories --- evomaintenance.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/evomaintenance.sh b/evomaintenance.sh index 34e59b9..5e9625b 100644 --- a/evomaintenance.sh +++ b/evomaintenance.sh @@ -55,9 +55,23 @@ echo "${BLOB}" >> "${LOGFILE}" GIT_BIN=$(command -v git) if test -x "${GIT_BIN}"; then - export GIT_DIR=/etc/.git - ${GIT_BIN} add . - ${GIT_BIN} commit --all --message "${TEXTE}" --message "${BLOB}" --author="${USER} <${USER}@evolix.net>" --quiet + # loop on possible GIT repositories + for dir in /etc/.git /etc/bind/.git; do + # tell Git where to find the repository (no need to `cd …` there) + export GIT_DIR="${dir}" + # If the repository exists, try to commit changes + if test -d "${GIT_DIR}"; then + ${GIT_BIN} add . + ${GIT_BIN} commit --all --message "${TEXTE}" --author="${USER} <${USER}@evolix.net>" --quiet + # Add the SHA to the log file if something has been committed + if [ "$?" = "0" ]; then + SHA=$(git rev-parse --short HEAD) + echo "${GIT_DIR} : ${SHA}" >> "${LOGFILE}" + fi + fi + + unset GIT_DIR + done fi # insert into PG