#!/bin/csh -f
#
# BIWEEKLY.ATRIM
#
#	This script trims the dhistory file.
#
#	ALWAYS RUN MANUALLY ONCE AFTER MAKING ANY CHANGE, TO BE SURE
#	THE SCRIPT STILL WORKS!

cd ~

if ( "$argv" != "locked" ) then
    dbin/plock ~/.lock adm/$0 locked
    exit 0
endif

echo "`date` - $0 BEGIN"

set dhistory = `dbin/dpath dhistory`
set dactive = `dbin/dpath server_dactive`

# pause diablo
#
# rebuild the history file, removing
# any expired entries over 16 days old.
#
# remove the old backup to give us more
# disk space to play with.

rm -f ${dhistory}.new
rm -f ${dhistory}.bak

# To increase the hash table size, change the hsize parameter
# in diablo.config.
# see diablo.config for more information.

dbin/dhisexpire -a ${dhistory}

set savestatus = $status

#
# always ensure that *some* dhistory file
# exists no matter what the failure condition
#

# This is safer, it will generate an error if it cannot
# trim the dactive.kp file (which is basically: never while
# dreaderd is running, but at least this won't blow things up)
#
dbin/dkp -t ${dactive}

echo "`date` - $0 END"

