[Exim] "portable" (ho ho) init.d script

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Matt Bernstein
Datum:  
To: exim-users
Betreff: [Exim] "portable" (ho ho) init.d script
The below script depends only on exiwhat (which itself depends on a Bourne
shell and awk amongst others) and sleep. Thoughts on how to cure the
sleep, though it's only for the cosmetic subsequent line, as well as other
criticisms welcome! It ought to work on all UNIX flavours.

This was inspired by trying (and failing) to get the Debian
start-stop-daemon stuff to do what I wanted when adding a second daemon.

#!/bin/sh
#/etc/init.d/exim (or wherever your system would prefer it)

#set this to include where you built Exim
PATH=$PATH:/usr/local/sbin

#you may need to tune the awk if Exim changes in the future
sig() {
    exiwhat | awk '/listening for SMTP/ { print $1 }' | while read p
    do
        echo -n " ($p"
        kill -$1 $p
        echo -n ")"
    done
}


# bail out if we feel nervous
set -e

# to stop exiwhat killing this script!
trap "" SIGUSR1

case "$1" in
    start)
        echo -n "Starting Exim"
        exim -bd -q10m
        #comment out the below line if you're using < 4.03
        exim -bd -oX '[0.0.0.0]::465' -tls-on-connect
        sleep 1
        sig USR1
        echo "."
        ;;
    stop)
        echo -n "Stopping Exim"
        sig TERM
        echo "."
        ;;
    restart)
        $0 stop
        $0 start
        ;;
    force-restart)
        echo -n "Forceably killing Exim"
        sig KILL
        echo "."
        $0 start
        ;;
    reload|force-reload)
        echo -n "Reloading Exim configuration"
        sig HUP
        echo "."
        ;;
    *)
        echo "Usage: $0 {start|stop|restart|force-restart|reload|force-reload}"
        exit 1
        ;;
esac


exit 0