source: TRACY3/trunk/tracy/tools/cvs-loginfo.sh @ 8

Last change on this file since 8 was 3, checked in by zhangj, 12 years ago

Initiale import

  • Property svn:executable set to *
File size: 1.9 KB
Line 
1#! /bin/sh
2
3# /usr/local/bin/cvs-commitinfo.sh et /usr/local/bin/cvs-loginfo.sh
4# Scripts de notification par mail des commits du CVS
5# Version 1.2
6# Scripts écrits par Boris DorÚs <babal@via.ecp.fr> - 2003
7# Formation Debian GNU/Linux par Alexis de Lattre
8# http://formation-debian.via.ecp.fr/
9
10
11# Pour mettre en place la notification par mail :
12# 1) copiez les fichiers cvs-loginfo.sh et cvs-commitinfo.sh dans le répertoire
13#    /usr/local/bin/
14#
15# 2) ajoutez dans le fichier
16#    /var/lib/cvs/nom_du_projet/CVSROOT/commitinfo la ligne suivante :
17
18#ALL /usr/local/bin/cvs-commitinfo.sh
19
20# 3) ajoutez dans le fichier
21#    /var/lib/cvs/nom_du_projet/CVSROOT/loginfo la ligne suivante :
22
23#ALL /usr/local/bin/cvs-loginfo.sh adresse_de_provenance adresse_destination "Sujet_des_mails" $USER
24
25
26# parameters
27mailfrom="$1";
28mailto="$2";
29subject="$3";
30user="$4";
31
32# external programs
33AWK=/usr/bin/awk
34CAT=/bin/cat
35CSPLIT=/usr/bin/csplit
36CUT=/usr/bin/cut
37FIND=/usr/bin/find
38GREP=/bin/grep
39MAIL=/usr/bin/mail
40RM=/bin/rm
41WC=/usr/bin/wc
42
43# temporary files
44directories="/tmp/cvslog.$PPID.directories"
45log="/tmp/cvslog.$PPID"
46pattern="/tmp/cvslog.$PPID.$$."
47head="/tmp/cvslog.$PPID.$$.00"
48message="/tmp/cvslog.$PPID.$$.01"
49
50
51# split the loginfo message
52$CSPLIT -qf "$pattern" - "/Log Message:/"
53$GREP -hv '^In directory' "$head" | $GREP -hv '^$' >> "$log"
54echo >> "$log"
55
56# is it the last directory ?
57NB_MAIL=`$GREP '^$' "$log" 2> /dev/null | $WC -l`
58if ( test -f "$directories" )
59then
60        NB_COMMIT=`$CAT "$directories" | $WC -l`
61else
62        NB_COMMIT=1
63fi
64if [[ $NB_MAIL -ge $NB_COMMIT ]]
65then
66        # complete and send the mail
67        $AWK  'BEGIN { n=0 ; } { if ( $0 ~ "^[ \t\f\n\r\v]*$" ) { n++; } else { for ( i=0; i<n; i++ ) printf "\n"; print $0; n=0; } }' "$message" >> "$log"
68        echo -e "\n-- \n$user" >> "$log"
69        $CAT "$log" | $MAIL -s "$subject ($user)" -a "From: $mailfrom" "$mailto"
70        # clean up
71        $RM -f $log
72        $RM -f $directories
73fi
74
75# clean up
76$RM -f "$pattern"*
Note: See TracBrowser for help on using the repository browser.