Commit | Line | Data |
---|---|---|
25469895 P |
1 | #!/bin/sh |
2 | recipients="root+git" # adresse pour l'envoi du mail | |
3 | ||
6d90c319 P |
4 | PATH="/bin:/usr/bin" |
5 | export PATH | |
6 | ||
25469895 P |
7 | if [ "$1" != "cron" ]; then |
8 | echo "Ce script n'est pas fait pour être lancé manuellement mais via cron." | |
9 | exit -1 | |
10 | fi | |
11 | ||
12 | [ -x /usr/bin/git -a -d /.git ] || exit 0 | |
13 | ||
ff92b1af P |
14 | tempfile=`tempfile` |
15 | if [ $? != 0 ]; then | |
16 | echo "Erreur fatale de création de fichier temporaire." | |
17 | exit -1 | |
18 | fi | |
19 | trap "rm -f \"$tempfile\"" 0 1 2 3 15 | |
20 | ||
21 | (cd / ; /usr/bin/git status -a) | | |
6d90c319 | 22 | sed -e '1{/^# On branch /d};2{/^nothing to commit/d};s/^#//' >"$tempfile" |
ff92b1af P |
23 | |
24 | if [ -s "$tempfile" ]; then | |
25469895 | 25 | ( |
c80ec8d7 | 26 | echo "From: git `hostname --fqdn` - Cron Daemon <root+git@`cat /etc/mailname`>" |
25469895 P |
27 | echo "To: ${recipients}" |
28 | echo "Date: `date --rfc-2822`" | |
c80ec8d7 | 29 | echo "Subject: git-status: `hostname --fqdn` - $0" |
25469895 P |
30 | echo "Content-Type: text/plain; charset=utf-8" |
31 | echo "" | |
c80ec8d7 | 32 | echo "Voici la liste de modifications sur la machine `hostname --fqdn` qui n'ont pas encore été validées :" |
25469895 P |
33 | echo "( voir http://wiki.auf.org/wikiteki/Git/SuiviDeConfiguration )" |
34 | echo "" | |
ff92b1af | 35 | cat "$tempfile" |
25469895 | 36 | ) | head -c 16k | /usr/sbin/sendmail ${recipients} |
ff92b1af P |
37 | fi |
38 | ||
25469895 | 39 | exit 0 |