#!/bin/bash
# Copyright (C) 2005 McAfee Inc. All rights reserved.
# $Header: /cvs/WebShield/wsrc/files/mgmt/Attic/spamcheck,v 1.1.2.3 2005/02/15 12:29:51 rhonnava Exp $
#
#
shopt -s extglob
shopt -s nullglob

me=${0##*/}
count=0
while true 
do
	# is spamd responding?
	if /usr/sbin/webshield try_spamd 
	then
		count=0
		sleep 60
		continue
	fi

	# should it be running?
	/sbin/chkconfig spamassassin_jail || exit 0	# no? - get out of here

	if (( ++count > 3 ))
	then	# no response 4th time of asking - restart it
		logger -t "$me" "Spamassassin being restarted by health check"
		/etc/init.d/spamassassin_jail restart
		count=0
	fi
	sleep 60
done

