#!/bin/sh -
#---------------------------------------------------------------------------
#
#	rotate isdn4bsd isdntrace logfiles
#	==================================
#
#	last edit-date: [Tue Nov 14 14:05:37 2000]
#
#	This script rotates isdntrace(8) logfiles and deletes the 
#	oldest ones. isdntrace needs to be started for this to
#	function with the option "-f /var/tmp/isdntrace0", i.e.
#	an entry like:
#		isdn_traceflags="-f /var/tmp/isdntrace0"
#	in /etc/rc.conf will be sufficient. Further, you need to
#	add an entry like this or similar to this:
#		0 0 * * * root /usr/local/etc/doisdnrot 2>&1 | sendmail root
#	to /etc/crontab to rotate the logfiles at every midnight.
#
#---------------------------------------------------------------------------
PATH=/bin:/usr/bin
host=`hostname -s`
echo "Subject: $host isdntrace logfile rotation"

isdntracepid=`ps -x | grep isdntrace | grep -v grep | awk '{print $1}'`

if [ $isdntracepid ]
then
	echo "executing kill -USR1 $isdntracepid ..."
	kill -USR1 $isdntracepid
else
	echo "isdntrace not running, pid is $isdntracepid"
fi

echo "removing files older than 7 days:"
find /var/tmp -name isdntrace0\* -type f -mtime +7 -print -delete

echo "finished...."
exit 0
