#!/bin/sh
# E2Guardian logrotation script for version 5.5.6r


LOG_DIR=/var/log/e2guardian
NUM_LOGS=4
LOG=$LOG_DIR/access.log

/usr/pkg/sbin/e2guardian -q

# Keep a maximum of $NUM_LOGS logs around.
if [ -f $LOG.$NUM_LOGS ]; then rm -f $LOG.$NUM_LOGS; fi
n=$(( $NUM_LOGS - 1 ))
while [ $n -gt 0 ]; do
  if [ -f $LOG.$n ]; then
    mv $LOG.$n $LOG.$(( $n + 1 ))
  fi
  n=$(( $n - 1 ))
done
if [ -f $LOG ]; then
  mv $LOG $LOG.1
fi

sleep 5

/usr/pkg/sbin/e2guardian
