#!/bin/sh
# $FreeBSD$

# PROVIDE: syscache
# REQUIRE: LOGIN cleanvar
# KEYWORD: shutdown

#
# Add the following lines to /etc/rc.conf to enable syscache:
# syscache_enable (bool):		Set to "NO" by default.
#				Set it to "YES" to enable syscache 

. /etc/rc.subr

name="syscache"
rcvar=syscache_enable

command="/usr/local/bin/syscache-daemon"
command2="/usr/local/bin/syscache"
start_cmd="syscache_start"
stop_cmd="syscache_stop"

[ -z "$syscache_enable" ]		&& syscache_enable="NO"

load_rc_config $name

syscache_start()
{
  echo "Starting syscache..."
  if [ -e "/var/run/syscache.pipe" ] ; then
    rm /var/run/syscache.pipe >/dev/null 2>/dev/null
  fi
  (export PATH="${PATH}:/usr/local/bin:/usr/local/sbin"; nice $command >/dev/null 2>/dev/null) &
}

syscache_stop()
{
  ${command2} shutdowndaemon >/dev/null 2>/dev/null
}

run_rc_command "$1"
