[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Where to put a custom system cleanup script?



On Mon, Jan 28, 2008 at 03:57:29PM +0100, Dan H. wrote:
> On Mon, Jan 28, 2008 at 03:22:41PM +0100, Dan H. wrote:
> > for a home computer that gets shutdown daily, I'd like to implement a
> > function which:
> > 
> > 1. makes sure that all pending outgoing mails are sent off. 
> 
> Here's what I've come up with. Anything not to like?
> 
> #!/bin/sh
> 
> # install with this as root:
> # # update-rc.d flushmail defaults 21 19
> # assuming that exim has sequence number 20 on startup and shutdown.
> 
> 
> ### BEGIN INIT INFO
> # Provides:          flushmail
> # Required-Start:
> # Required-Stop:     exim4 mail-transport-agent
> # Should-Start:
> # Default-Start:
> # Default-Stop:      0 1 6
> # Short-Description: Flush mail queue
> ### END INIT INFO
> 
> set -e
> 
> QUEUERUNNER="/usr/sbin/runq"
> 
> if [ ! -x $QUEUERUNNER ] ; then exit 1 ; fi
> 
> case "$1" in
>   start)
>   echo "Not flushing on startup"
>   ;;
>   
>   restart|stop)
>   echo -n "Flushing mail queue..."
>   $QUEUERUNNER
>   echo "done."
>   ;;
> esac
> 
> exit 0

You may want to touch /etc/nologin while this happens, then remove it at
the end of the script.  It can also include the backup scripts he
wishes.

Doug.


Reply to: