#!/bin/sh
set -u  # force better programming and ability to use check for not set
if [ "${1:-}" = "-x" ] ; then set -xv; shift; fi
. /usr/local/etc/setups.sh
setup python
source $ENSTORE_DIR/sbin/gettkt

cd
basedir=`pwd`/enstore

output=$basedir/repository-production
rm -f $output

dirs=/tmp/dirs
rm -f $dirs

export CVS_RSH=/usr/krb5/bin/rsh
rm -fr lz >/dev/null 2>&1
mkdir lz  >/dev/null 2>&1
cd lz

CVSROOT=hppccvs@cdcvs.fnal.gov:/cvs/hppc
export CVSROOT

cvs co enstore >/dev/null 2>&1
if [ $? != 0 ]; then
    exit 1
fi

date >> $output
echo "List of files in $CVSROOT without production tag" >> $output

#find enstore -type f -exec /home/bakken/lz/enstore/tools/notready.py {} \; | egrep -v 'Checking files...|ok$|not in CVS, skipping$|is a directory, ignoring|in in /CVS/ directory. Can not possibly check it' >> $output

/usr/bin/find * -type d | egrep -v "CVS|ingest" > $dirs
cat $dirs | while read d; do
 (cd $d; $basedir/tools/notready.py *| egrep -v 'Checking files...|ok$|not in CVS, skipping$|is a directory, ignoring|in in /CVS/ directory. Can not possibly check it|Cannot parse cvs output' >> $output )
done

date >> $output

/usr/bin/Mail -s "Nonproduction files in cvs repository" enstore-auto@fnal.gov <$output
#/usr/bin/Mail -s "Nonproduction files in cvs repository" moibenko@fnal.gov <$output
