#! /bin/sh
#
# cron script to rotate sendfile log files.

if [ -d /var/log/sendfile ]
then

    cd /var/log/sendfile

    savelog -c 7 in.log out.log >/dev/null
fi

if [ -d /var/spool/sendfile ]
then

    cd /var/spool/sendfile

    if [ -n "`ls`" ]; then
	for u in *; do
	    if [ -f $u/log.7 ]; then rm -f $u/log.7; fi
	    for num in 6 5 4 3 2 1; do
		np=`expr $num + 1`
		if [ -f $u/log.$num ]; then mv -f $u/log.$num $u/log.$np; fi
	    done
	    if [ -f $u/log ]; then mv -f $u/log $u/log.1; fi
	done
    fi
fi
