Sophie

Sophie

distrib > Mandriva > 9.0 > x86_64 > media > main > by-pkgid > e75c59cda688dab025c67b83b89418b1 > files > 2

sarg-1.2.2-2mdk.x86_64.rpm

#!/bin/bash

#dynamic counter
cnt=1

if [ $cnt -eq 4 ]; then
#Get yesterday date
YESTERDAY=$(date --date "1 day ago" +%d/%m/%Y)
 
#Get 4 weeks ago date
WEEKSAGO=$(date --date "4 weeks ago" +%d/%m/%Y)

mkdir -p /var/www/html/squid/monthly 
chown -R apache /var/www-naat/html/genfiles/modules/squid-reports/monthly 

/usr/sbin/sarg -f /etc/sarg/sarg.conf -l /var/log/squid/access.log -o /var/www/html/squid/monthly -d $WEEKSAGO-$YESTERDAY > /dev/null 2>&1
 
/usr/sbin/squid -k rotate

#don't move next line to upper, reason is that sed change the cnt assignment of the first 7 lines
cnt=1 
else
let cnt++
fi
#echo Will rename itself \($0\) with cnt \($cnt\) increased. 1>&2
sargtmp=/var/tmp/`basename $0`
sed "1,7s/^cnt=.*/cnt=$cnt/
" $0 >|$sargtmp
chmod -f 775 $sargtmp
mv -f $sargtmp $0