#!/bin/sh
#
#
#

# PROVIDE: htcacheclean

#
# Configuration settings for htcacheclean in /etc/rc.conf
#
# htcacheclean_enable (bool) 
# Set to "NO" by default 
# Set it to "YES" to enable htcacheclean
#
# htcacheclean_cache (str) Set to "/usr/local/www/proxy" by default Set the
# location of the mod_disk_cache CacheRoot This should be the same as whats in
# your httpd.conf
#
# htcacheclean_cachelimit (str) Set to "512M" by default Sets the size
# htcacheclean should prune the disk cache to expressed in bytes by default, K
# for kilobytes, M for megabytes.
#
# htcacheclean_interval (num) 
# Set to "10" by default
# Sets how frequently in munutes htcacheclean wakes up and prunes the cache
#
# htcacheclean_args (str)
# Set to "-t -n -i" by default
# Sets extra command-line arguments to htcacheclean
# -t Delete all empty directories
# -n Be nice by sleeping occasionally to not saturate the I/O bandwith of the disk
# -i Run only when there was a modification of the disk cache

. /etc/rc.subr

htcacheclean_enable="${htcacheclean_enable:-"NO"}"
htcacheclean_cache="${htcacheclean_cache:-"/usr/local/www/proxy"}"
htcacheclean_cachelimit="${htcacheclean_cachelimit:-"512M"}"
htcacheclean_interval="${htcacheclean_interval:-"60"}"
htcacheclean_args="${htcacheclean_args:-"-t -n -i"}"


name="htcacheclean"
rcvar=`set_rcvar`

start_precmd="htc_check"
restart_precmd="htc_check"
restart_reload="htc_check"
load_rc_config "${name}"

command="/usr/local/sbin/htcacheclean"
flags="-p${htcacheclean_cache} -d${htcacheclean_interval} -l${htcacheclean_cachelimit} ${htcacheclean_args}"
required_dirs="${htcacheclean_cache}"

htc_check()
{
	[ ! -d ${htcacheclean_cache} ] && {
		echo ""
		return 1
	}
	return 0
}

run_rc_command "$1"
