--- spfmilter-0.97/rc_scripts/redhat 2005-08-08 12:16:59.218063678 +0100 +++ spfmilter-0.97/rc_scripts/redhat 2005-08-08 12:22:16.719864175 +0100 @@ -38,7 +38,7 @@ echo -n $"Starting spfmilter: " touch "$SPFMILTER_PIDFILE" chown spfmilt:spfmilt "$SPFMILTER_PIDFILE" - daemon /usr/sbin/spfmilter \ + daemon /usr/sbin/spfmilter-wrapper \ --user spfmilt \ --pidfile "$SPFMILTER_PIDFILE" \ --fallback "$SPFMILTER_FALLBACK" \ @@ -73,12 +73,14 @@ ;; restart|reload) stop + sleep 2 start RETVAL=$? ;; condrestart) if [ -f /var/lock/subsys/spfmilter ]; then stop + sleep 2 start RETVAL=$? fi --- /dev/null 2005-07-18 18:58:09.419765000 +0100 +++ spfmilter-0.97/rc_scripts/spfmilter-wrapper 2005-08-08 12:18:55.803567745 +0100 @@ -0,0 +1,32 @@ +#!/bin/bash +# +# spfmilter-wrapper - wrapper script for spfmilter +# +# This script backgrounds itself and then runs spfmilter in a loop. +# If the daemon exits then the script restarts it automatically. +# + +wrapper_dir=$(dirname "$0") +daemon=spfmilter +( + while : + do + # start the daemon in the foreground + $wrapper_dir/$daemon --nodaemon "$@" + 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/spfmilter ] && 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