#!/bin/sh
# chkconfig: 345 77 15
# description: Plesk Interface and Utilities

# Plesk source function library
#
# PROVIDE: psa-spamassassin
# REQUIRE: NETWORKING 
# BEFORE: DAEMON
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf to enable spamassassin:
#
#  spamassassin_enable="YES"
#
# This scripts takes one of the following commands:
#
#   start stop restart reload status 
#

. /usr/local/etc/rc.d/functions
. /etc/rc.subr

_pidprefix="/var/run/psa_spamassassin"
pidfile="${_pidprefix}.pid"

name="psa_spamassassin"

rcvar=`set_rcvar`
load_rc_config ${name}

#Set defaults
: ${psa_spamassassin_enable:-"NO"}
: ${psa_spamassassin_flags:-""}

command="/usr/local/psa/admin/bin/spamd"

start_cmd="spamassassin_common start"
stop_cmd="spamassassin_common stop"
status_cmd="status"
restart_cmd="restart"

spamassassin_common()
{
	local action="$1"

	$command --$action >/dev/null
}

status()
{
	$command --status | grep -q 'is running' && return 0 || return 1
}

restart()
{
	spamassassin_common stop
	spamassassin_common start
}

run_rc_command "$1"


