#!/bin/sh

if [ -f /usr/bin/logger ]
then
    msgcmd="/usr/bin/logger -t sargreport -p local0"
    msgcmdfail="$msgcmd.error "
    msgcmdinfo="$msgcmd.info "
else
    msgcmd="echo "
    msgcmdfail="echo "
    msgcmdinfo="echo "
fi

lastday=`/usr/local/bin/date --date "1 day ago" +%d/%m/%Y`
lastmonth=`/usr/local/bin/date --date "1 month ago" +%d/%m/%Y`

$msgcmdinfo "creating sarg report for $lastmonth-$lastday"
/usr/local/squid-addons/bin/sarg -d $lastmonth-$lastday
sleep 5; 
$msgcmdinfo "rotate the squid log files"
/usr/local/squid/sbin/squid -f /etc/squid/squid.conf -k rotate
    
