Sophie

Sophie

distrib > Fedora > 13 > i386 > media > updates-src > by-pkgid > 2f7e4f1e3b0cba9e0bebc1d9497ea9ac > files > 10

spamass-milter-0.3.1-21.fc13.src.rpm

#!/bin/bash
#
# spamass-milter-wrapper - wrapper script for spamass-milter
#
# This script backgrounds itself and then runs spamass-milter in a loop.
# If the daemon exits then the script restarts it automatically.
#

wrapper_dir=$(dirname "$0")
daemon=spamass-milter
(
	while :
	do
		# start the daemon in the foreground
		$wrapper_dir/$daemon "$@"
		milter_status=$?
		milter_date=$(date)
		# exit if we're shutting down
		[ -f /etc/nologin ] && exit
		sleep 1
		# exit if we're deliberately stopped
		[ ! -f /var/lock/subsys/spamass-milter ] && exit
		# otherwise, send a notification about the daemon crash
		# and then restart
		sleep 9
		(
			echo "$daemon exited at $milter_date with status $milter_status"
			echo "You may wish to check /var/log/messages and/or /var/log/maillog"
		) | mail -s "$daemon on `hostname` restarted" root
	done
) >& /dev/null &
disown -ar