#!/bin/sh -e
#
# This housekeeping shell script is installed as /etc/cron.daily/wwwoffle.
# Cron automatically runs it once a day.
#
# This script simply runs 'wwwoffle -purge' to purge the cache and 
# discard the output. If you want to save the output, simply
# choose a name for the log file. If the log file exists, it is
# rotated every day.
#
#
# This scripts also runs wwwoffle-htdig-incr to generate an index over the 
# cached web pages.

WWWOFFLE_PURGE_LOG=

if test "x$WWWOFFLE_PURGE_LOG" = x ; then
    wwwoffle -purge -c /etc/wwwoffle/wwwoffle.conf >/dev/null 2>&1
else
    wwwoffle -purge -c /etc/wwwoffle/wwwoffle.conf \
	>"/var/log/$WWWOFFLE_PURGE_LOG" 2>&1
fi


# The problem is that the wwwoffle can only suggest the user to install 
# htdig, so we now have to check if it is installed at all !

if [ -x /usr/bin/htdig ]; then
	/usr/bin/wwwoffle-htdig-incr 	
fi	


