#!/bin/bash
# Copyright (C) 2005 McAfee Inc. All rights reserved.
# $Header: /cvs/WebShield/wsrc/files/mgmt/Attic/imapcheck,v 1.1.2.1 2005/02/11 15:30:35 hbalasub Exp $
#
#

shopt -s extglob
shopt -s nullglob

COUNT=0
while true 
do
	/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

