source: cvsmailer/cvsmailer.sh@ 376

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

Friendy the email address

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