Bug 10214 - Cleaning up partial messages at start/restart.
Summary: Cleaning up partial messages at start/restart.
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: sendmail (Show other bugs)
(Show other bugs)
Version: 8.0
Hardware: All Linux
medium
medium
Target Milestone: ---
Assignee: Florian La Roche
QA Contact:
URL:
Whiteboard:
Keywords: FutureFeature
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2000-03-16 22:14 UTC by Guy Fraser
Modified: 2008-05-01 15:37 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-03-26 09:31:06 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

Description Guy Fraser 2000-03-16 22:14:54 UTC
On high use mail servers, open connections are often broken. This leaves
incomplete data(df*) files without there control(qf*) files, and leaves the
transaction(xf*) file in the queue. I have a modified sendmail init that
can clean up the spool at startup and restart. I started with the RedHat
6.1 sendmail init file and part of an example from the Sendmail 8.10.0
operators guide. I put in support for multiple /var/spool/mqueue* queue
directories. I use a cascading queue system to increase the time between
deliveries as a messages ages. I don't know if sendmail 8.9.3 supports
multiple queues, but 8.10.0 does.

Take a look at my script:
----cut----
#!/bin/sh
#
# sendmail      This shell script takes care of starting and stopping
#               sendmail.
#
# Source from RedHat 6.1 Standard for Intel
# Modified by Guy Fraser For : The Internet Centre Ltd.
#
# chkconfig: 2345 80 30
# description: Sendmail is a Mail Transport Agent, which is the program \
#              that moves mail from one machine to another.
# processname: sendmail
# config: /etc/mail/sendmail.cf
# pidfile: /var/run/sendmail.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Source sendmail configuration.
if [ -f /etc/sysconfig/sendmail ] ; then
	. /etc/sysconfig/sendmail
else
	DAEMON=yes
	QUEUE=1h
fi

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

[ -f /usr/sbin/sendmail ] || exit 0

RETVAL=0

# See how we were called.
case "$1" in
  start)
# Start of modifications.
	for queue in /var/spool/mqueue*
	do
		cd $queue
		echo " Checking $queue"
		for xffile in [lnx]f*
		do
			if [ -f $xffile ]
		        then
				Xffile=`echo $xffile | sed 's/[lnx]f/\*f/'`
				echo " <stopped: $Xffile>"
				rm -f $Xffile
			fi
		done


# remove zero length qf files

		for qffile in qf*
		do
		        if [ -r $qffile ]
		        then
		        	if [ ! -s $qffile ]
		        	then
		        		echo " <zero: $qffile>"
		        		rm -f $qffile
		        	fi
		        fi
		done


# rename tf files to be qf if the qfdoes not exist

		for tffile in tf*
		do
			qffile=`echo $tffile | sed 's/tf/qf/'`
			if [ -r $tffile -a ! -f $qffile ]
			then
			     	echo " <recovering: $tffile>"
			     	mv $tffile $qffile
			else
			     	if [ -f $tffile ]
			     	then
			     		echo " <extra: $tffile>"
			     		rm -f $tffile
			     	fi
			fi
		done


# remove df files with no corresponding qf files

		for dffile in df*
		do
			qffile=`echo $dffile | sed 's/df/qf/'`
			if [ -r $dffile -a ! -f $qffile ]
			then
				echo " <incomplete: $dffile>"
				mv $dffile `echo $dffile | sed 's/df/Df/'`
#				rm -f $dffile
			fi
		done


# announce files that have been saved during disaster recovery

		for Dffile in [A-Z]f*
		do
			if [ -f $Dffile ]
			then
				echo " <panic: $Dffile>"
			fi
		done
	done

# end of modifications
	# Start daemons.

	echo -n "Starting sendmail: "
	/usr/bin/newaliases > /dev/null 2>&1
	for i in virtusertable access domaintable mailertable ; do
	    if [ -f /etc/mail/$i ] ; then
		makemap hash /etc/mail/$i < /etc/mail/$i
	    fi
	done
	daemon /usr/sbin/sendmail $([ "$DAEMON" = yes ] && echo -bd) \
                                  $([ -n "$QUEUE" ] && echo -q$QUEUE)
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/sendmail
	;;
  stop)
	# Stop daemons.
	echo -n "Shutting down sendmail: "
	killproc sendmail
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sendmail
	;;
  restart|reload)
	$0 stop
	$0 start
	RETVAL=$?
	;;
  status)
	status sendmail
	RETVAL=$?
	;;
  *)
	echo "Usage: sendmail {start|stop|restart|status}"
	exit 1
esac

exit $RETVAL
------Cut------

Comment 1 Cristian Gafton 2000-05-22 15:51:59 UTC
assign to laroche

Comment 2 Florian La Roche 2003-03-26 09:31:06 UTC
I don't think this should be done on startup, will close this bugzilla entry.

greetings,

Florian La Roche



Note You need to log in before you can comment on or make changes to this bug.