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

# Debian only begin
cd /var/log/sendfile

savelog -c 7 {in,out}.log >/dev/null
# Debian only end

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