#!/bin/sh
#
# Submit path statistics based on ninpaths
# $Id: sendinpaths,v 1.2 1998/03/28 23:37:40 olaf Exp $

# Assuming the ninpaths dump files are in ${MOST_LOGS}/path/inpaths.%d

. /var/lib/news/innshellvars
cd ${MOST_LOGS}/path
ME=`innconfval pathhost`
report=30
keep=14
TMP=tmp$$

trap "rm -f $TMP; trap 0; exit" 0 1 2 15
# Make report from (up to) $report days of dumps
find . -name 'inpaths.*' -not -empty -mtime -$report -print |\
 sed 's/^/-u /' > $TMP

if [ "$1" = "-n" ] ; then
  ninpaths `cat $TMP` -r $ME
else
  ninpaths `cat $TMP` -r $ME |\
   $MAILCMD -s "inpaths $ME" pathsurvey@pathsurvey.eu.org
  # remove dumps older than $keep days
  find . -name 'inpaths.*' -mtime +$keep -print | xargs -r rm
fi

exit 0
