#!/bin/bash
# Copyright (C) 2005 McAfee Inc. All rights reserved.
# $Header: /cvs/WebShield/wsrc/files/mgmt/Attic/imapcheck,v 1.1.2.2 2005/05/31 12:24:22 bwhittak Exp $
#
#

shopt -s extglob
shopt -s nullglob

COUNT=0
while true 
do
	[[ ! - e /var/lock/subsys/cyrus ]] ||
	    /usr/sbin/webshield try_imapd > /dev/null 2>&1
	if [ $? = 0 ]
	then
		COUNT=0
	else
		(( COUNT++ ))
	fi

	if [ $COUNT -gt 3 ]
	then
		/etc/init.d/cyrus restart
		COUNT=0
	fi
	sleep 60
done

