#!/bin/sh
##
## track_rcs_usage - create a condensed summary for a project manager
## of rcs usage.  This script is run from cron, so its granularity can be
## modified.
##
## Arve Kjoelen - Thu Aug 22 16:20:26 CDT 1996
##

## who are we sending the summary to?

## What's our rcs track file?
trackfile=/opt/cvipapps/CVIPtools3.1/docs/.rcstrack

## A temporary file
tempfile=/tmp/AA_message
touch $tempfile
echo "RCS SUMMARY FOR THE LAST 14 DAYS:" >> $tempfile
echo "=================================" >> $tempfile
echo "" >> $tempfile
for user in `cat /etc/group | grep cvipadm | awk -F: '{print $4}' | awk -F, '{for (j=NF; j>0; --j) print $j}'`
do
   cat $trackfile | grep user
   if [ $? = 0 ]
   then
      touch /tmp/${user}.rcs
      egrep $user $trackfile >> /tmp/${user}.rcs
      echo "" >> $tempfile
      echo $user >> $tempfile
      echo "============" >> $tempfile
      echo $user has performed `wc -l /tmp/${user}.rcs` RCS operations.  >> $tempfile
      echo on `cat /tmp/${user}.rcs | awk '{print $2}' | sort -u` different files >> $tempfile
      echo detailed info:
      cat /tmp/${user}.rcs >> $tempfile
      rm -f /tmp/${user}.rcs
   fi
done
for i in akjoele
do
   /usr/ucb/mail -s 'CVIPtools RCS Usage Summary' $i < $tempfile
done
rm -f $tempfile
mv $trackfile $trackfile.bak
touch $trackfile
chmod 666 $trackfile
