#!/bin/sh

COMDIR=/usr/lib/atsar
LOGDIR=/var/log/atsar
CURDAY=`date +%d`

if [ ! -d $LOGDIR ]
then
	echo $0: directory $LOGDIR not present >&2
	exit 1
fi

# if the file we're about to write to is older than today (e.g., if we've
# gone a month and we're reusing a two digit day) I'll actually build in a 
# little slack in case the system's running slow for some reason
find $LOGDIR/atsa$CURDAY -mtime +2 -type f -exec rm {} \; 2> /dev/null

if [ -f /etc/atsar.conf ]
then
	$COMDIR/atsaftp     # count  ftp-requests added since previous call
	$COMDIR/atsahttp    # count http-requests added since previous call
fi

if [ $# = 0 ]
then
	$COMDIR/atsadc 1 1 $LOGDIR/atsa$CURDAY 2> /dev/null
else
	$COMDIR/atsadc $*  $LOGDIR/atsa$CURDAY 2> /dev/null
fi

exit 0
