#!/bin/sh
#
# This housekeeping shell script is installed as /etc/cron.daily/dwww.
# Cron automatically runs it once a day.
#
# This script re-builds the dwww web pages, and removes old documents
# from the cache that have not been accessed for some number of days.
# The number of days should be configured by setting the DWWW_KEEPDAYS
# variable in /etc/default/dwww.  The value set in this script is a
# default; don't modify it, or an upgrade will wipe out your modification.

DWWW_KEEPDAYS=10
DWWW_QUICKFIND_DB=/var/lib/dwww/quickfind.dat
if test -r /etc/dwww.conf
then
	. /etc/dwww.conf
fi

dwww-build --default >/dev/null
find /var/lib/dpkg/info -name '*.list' |
	dwww-quickfind --build $DWWW_QUICKFIND_DB.new
mv -f $DWWW_QUICKFIND_DB.new $DWWW_QUICKFIND_DB
find /var/spool/dwww -atime +$DWWW_KEEPDAYS -name '[^.]*' \
	-maxdepth 1 -type f -print0 | xargs -0 rm -f
dwww-cache --clean
