#! /bin/sh
#
# cron script to rotate httpd log files.
#
# Written by Ian A. Murdock <imurdock@debian.org>
# modified for HTTPD by Ted Hajek <tedhajek@boombox.micro.umn.edu>
#cd /var/log
conffile=/etc/cern-httpd.conf
acclog=`grep -Ei '^\W*accesslog\W+' $conffile | awk '{print $2}'` 
errlog=`grep -Ei '^\W*errorlog\W+' $conffile | awk '{print $2}'` 
for LOG in $acclog $errlog
do
   if [ -f $LOG ]; then
      savelog -g adm -m 644 -u root -c 4 $LOG > /dev/null
   fi
done
#
# restart the server to reopen the log files, if
# we think it's running standalone. If it's being 
# started by inetd, it should re-open logs the
# next time it's run.
#
grep -Eqi '^\W*port\W+[[:digit:]]+' /etc/cern-httpd.conf \
   || grep -Eqi '^\W*servertype\W+standalone+' /etc/cern-httpd.conf \
   && /usr/sbin/cern-httpd -restart 2> /dev/null
