From 140fd58766248f0ca2a891307ecd86005e4af6b3 Mon Sep 17 00:00:00 2001 From: Daniel STAN Date: Sun, 2 Nov 2014 23:54:57 +0100 Subject: [PATCH] =?UTF-8?q?utils/check=5Frepos:=20v=C3=A9rifie=20la=20sync?= =?UTF-8?q?hro=20du=20d=C3=A9p=C3=B4t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/check_repos.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 utils/check_repos.sh diff --git a/utils/check_repos.sh b/utils/check_repos.sh new file mode 100755 index 00000000..9863c134 --- /dev/null +++ b/utils/check_repos.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Petit script qui surveille les dépôts git de /usr/scripts +# En cas de dépôt non pullé, ou si des commits n'ont pas +# été envoyés, une alerte est lancée. + +# Paths des dépôts à surveiller +GIT_REPOS="/usr/scripts /usr/scripts/lc_ldap" + +# Intervalle entre deux fetchs +PERIOD=5 + +check_repo () { + echo "vérification de $1" + cd $1 + ( git status | grep "# Your branch" -q ) && { + echo "...et dépôt pas à jour" + exit 42 + } +} + +fetch_updates () { + if test ! "`find .git/FETCH_HEAD -mmin +$PERIOD`"; then + return + fi + umask 002 + echo "fetching $1" + cd $1 + git fetch origin > /dev/null +} + +# Et on check que les repos sont ok +for dir in $GIT_REPOS; do + fetch_updates $dir + check_repo $dir +done + + +exit 0