#!/bin/sh
# Watch the CVS repository for changes in trf, retrieve the
# changed files and invoke the handler script which propagate the
# changes to other parts of the system.

cd `dirname $0`/..

export CVSROOT
CVSROOT=:pserver:anonymous@cvs1:/cvsroot/trf

if [ 0 -lt `cvs -d $CVSROOT diff trf 2>/dev/null | wc -l` ]
then
	out=$HOME/logs/trf
	mkdir -p `dirname $out`

	cvs -d $CVSROOT co trf >$out 2>&1
	mkdir -p trf/htdocs/state

        # Use a new htdocs_setup script immediately.
        # Without this copying it would take effect
        # only after with the change after the current
        # one.

        cp ./trf/tools/htdocs_setup ./tools/htdocs_setup

	(sleep 60 ; ./tools/htdocs_setup ) &
fi
exit
