#! /bin/sh
#
# Run daily to cycle through a weeks worth of DP log files..
#
. /etc/dp.conf
#
# SAF directory to look for files
#
SAFDIR=/var/saf
#
#
RotateDpLog()
{
    File=$1
    if [ -d ${DPLOG_DIR} ] ; then
	cd ${DPLOG_DIR}
	if [ -s $File ] ; then
	    rm -f Old/$File.5 Old/$File.6 Old/$File.7
	    test -f Old/$File.3 && mv Old/$File.3  Old/$File.4
	    test -f Old/$File.2 && mv Old/$File.2  Old/$File.3
	    test -f Old/$File.1 && mv Old/$File.1  Old/$File.2
	    test -f Old/$File.0 && mv Old/$File.0  Old/$File.1
	    cp $File Old/$File.0
	    chgrp other  $File Old/$File.0
	    chmod 644    $File Old/$File.0
	    cp /dev/null $File
	fi
    fi
}
RotateSafLog()
{
    Dir=$SAFDIR/$1   
    if [ -d $Dir -a -s $Dir/log ] ; then
	cd $Dir
	test -f log.4 && mv log.4  log.5
	test -f log.3 && mv log.3  log.4
	test -f log.2 && mv log.2  log.3
	test -f log.1 && mv log.1  log.2
	cp -p log log.1
	cp /dev/null log
    fi
}
#
#
RotateDpLog dp.log
RotateDpLog req.trace
RotateDpLog ttymon.log
#
RotateSafLog stsmon
RotateSafLog zsmon
