#! /bin/sh
#
# Run cfengine if both the executable and config file are available.
# Support for retrieving admin files from CVS or RCS is included.
#
# Written by Brian White <bcwhite@pobox.com>
# modified for Mandrakelinux by Frederic Lepied <flepied@mandrakesoft.com>
# modified for Mandrakelinux by Guillaume Rousse <guillomovitch@mandrake.org>

# Source configuration
. /etc/sysconfig/cfengine

CFAGENT=/usr/sbin/cfagent
CFINPUTS=/etc/cfengine
export CFINPUTS

echo "===============================================================================" 
date 
echo "" 

if [ $CRON_CVS = 1 ]; then
    cd $CFINPUTS
    echo "----- Begin CVS Checkout -----"
    cvs -d $CRON_CVSROOT -q checkout -P -A $CRON_CVSMODULE 2>&1
    echo "-----  End  CVS Checkout -----"
    echo ""
fi

if [ $CRON_RCS = 1 ]; then
    echo "----- Begin RCS Checkout -----"
    find $CFINPUTS -type d -name RCS -exec "cd {}/..; co -q RCS/*" \; 2>&1
    echo "-----  End  RCS Checkout -----"
    echo ""
fi


if [ -f $CFINPUTS/cfagent.conf -o -f $CFINPUTS/update.conf ]; then
    $CFAGENT -v
fi

echo ""
