source: cvsmailer/cvsmailer.sh@ 114

Last change on this file since 114 was 114, checked in by Rick van der Zwet, 15 years ago

Initial commit CVS mailer script

  • Property svn:executable set to *
  • Property svn:keywords set to id
File size: 2.1 KB
Line 
1#!/bin/sh
2# Allow tracking on your CVS modules without the need of server access
3# put in cron * * * * *
4# Works only properly if your receive one commit a minute.
5# Rick van der Zwet <info@rickvanderzwet.nl>
6# License BSD: http://rickvanderzwet.nl/LICENSE
7
8CVSDIR=/home/rick/wk2010
9EMAIL_TO="info@rickvanderzwet.nl"
10EMAIL_CC="derk_mus@hotmail.com,mnwsmit@gmail.com,mluiten@artifix.net"
11EMAIL_FROM="noreply@rickvanderzwet.nl"
12
13# System internal variables
14TMPDIR=`mktemp -d -t $(basename $0 .sh)`
15CVSLOG=$TMPDIR/cvs.log
16CVSLOG_STDERR=$TMPDIR/cvs.log.stderr
17CVSPROJECT=wk2010
18EMAIL_BODY=$TMPDIR/email-body.txt
19EMAIL_FULL=$TMPDIR/email-full.msg
20
21UPDATED=""
22AUTHOR="unknown"
23UPDATED_FILES=""
24
25{
26cd $CVSDIR
27
28# Changes in repository
29touch $CVSLOG_STDERR
30cvs -q up 2>$CVSLOG_STDERR | tee $CVSLOG
31UPDATED_FILES=`awk '/^[U|P]/ {print $2}' $CVSLOG`
32echo ""
33
34# Deleted files
35if [ -s $CVSLOG_STDERR ]; then
36 cat $CVSLOG_STDERR
37 echo ""
38 UPDATED="yes"
39fi
40
41if [ -n "$UPDATED_FILES" ]; then
42 # Log message
43 UPDATED_FILE=`echo $UPDATED_FILES | awk '{print $1}'`
44 cvs log -l -r$REV $UPDATED_FILE | sed -n '/-----/,/========/p'
45 echo ""
46
47 # Diff of files
48 for FILE in $UPDATED_FILES; do
49 UPDATED="yes"
50 REV=`cvs log -h $FILE | awk '/^head:/ {print $2}'`
51 PREV=`echo $REV | awk -F. '{print $1 "." $2 - 1}'`
52 cvs diff -N -u -r $PREV -r $REV $FILE
53
54 # Should be the same for all files
55 AUTHOR=`cvs log -l -r$REV $FILE | awk '/^date:/ {print $6}' | tr -d ';'`
56 done
57fi
58} > $EMAIL_BODY
59
60
61# Send email if updated
62if [ -n "$UPDATED" ]; then
63 {
64 echo "To: $EMAIL_TO"
65 if [ -n "$EMAIL_CC" ]; then
66 echo "Cc: $EMAIL_CC"
67 fi
68 echo "From: 'CVS Commit - $AUTHOR' <$EMAIL_FROM>"
69 echo "Subject: CVS Update $CVSPROJECT `echo $UPDATED_FILES`"
70 if [ -n "$EMAIL_CC" ]; then
71 echo "Reply-To: $EMAIL_TO,$EMAIL_CC"
72 else
73 echo "Reply-To: $EMAIL_TO"
74 fi
75 echo "X-Mailer: cvsmailer - $CVSPROJECT"
76 echo 'X-Version: $Id$'
77 echo ""
78
79 cat $EMAIL_BODY
80 echo ""
81 echo "==== ALL DONE generated by `id -un`@`hostname` at `date` ===="
82 } > $EMAIL_FULL
83 cat $EMAIL_FULL | /usr/sbin/sendmail -t
84fi
85
86rm -R $TMPDIR
Note: See TracBrowser for help on using the repository browser.