bdea17a
#!/bin/sh
bdea17a
#
418b70b
# postgrey     Postfix Greylisting Policy Server
bdea17a
#
418b70b
# chkconfig:   - 79 31
418b70b
# description: Postfix Greylisting Policy Server
418b70b
418b70b
### BEGIN INIT INFO
418b70b
# Provides: postgrey
418b70b
# Required-Start: $local_fs $network
418b70b
# Required-Stop: $local_fs $network
418b70b
# Should-Start: 
418b70b
# Should-Stop: 
418b70b
# Default-Start: 
418b70b
# Default-Stop: 0 1 2 3 4 5 6
418b70b
# Short-Description: Postfix Greylisting Policy Server
418b70b
# Description:       Postgrey is a Postfix policy server implementing
418b70b
#                    greylisting. When a request for delivery of a mail is
418b70b
#                    received by Postfix via SMTP, the triplet CLIENT_IP /
418b70b
#                    SENDER / RECIPIENT is built.  If it is the first time
418b70b
#                    that this triplet is seen, or if the triplet was first
418b70b
#                    seen less than 5 minutes, then the mail gets rejected
418b70b
#                    with a temporary error.
418b70b
### END INIT INFO
bdea17a
bdea17a
# Source function library.
bdea17a
. /etc/rc.d/init.d/functions
bdea17a
418b70b
exec="/usr/sbin/postgrey"
418b70b
prog="postgrey"
418b70b
options="--unix=/var/spool/postfix/postgrey/socket"
bdea17a
418b70b
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
bdea17a
418b70b
lockfile=/var/lock/subsys/$prog
bdea17a
bdea17a
start() {
418b70b
    [ -x $exec ] || exit 5
bdea17a
    echo -n $"Starting $prog: "
418b70b
    daemon $exec -d $options
418b70b
    retval=$?
bdea17a
    echo
418b70b
    [ $retval -eq 0 ] && touch $lockfile
418b70b
    return $retval
bdea17a
}
418b70b
bdea17a
stop() {
bdea17a
    echo -n $"Stopping $prog: "
418b70b
    killproc $prog
418b70b
    retval=$?
bdea17a
    echo
418b70b
    [ $retval -eq 0 ] && rm -f $lockfile
418b70b
    return $retval
bdea17a
}
bdea17a
bdea17a
restart() {
bdea17a
    stop
bdea17a
    start
bdea17a
}
bdea17a
bdea17a
reload() {
bdea17a
    echo -n $"Reloading $prog: "
418b70b
    killproc $prog -HUP
418b70b
    retval=$?
bdea17a
    echo
418b70b
    return $retval
418b70b
}
418b70b
418b70b
force_reload() {
418b70b
    restart
418b70b
}
418b70b
418b70b
rh_status() {
418b70b
    status $prog
418b70b
}
418b70b
418b70b
rh_status_q() {
418b70b
    rh_status &>/dev/null
bdea17a
}
418b70b
418b70b
bdea17a
case "$1" in
bdea17a
    start)
418b70b
        rh_status_q && exit 0
418b70b
        $1
418b70b
        ;;
bdea17a
    stop)
418b70b
        rh_status_q || exit 0
418b70b
        $1
418b70b
        ;;
bdea17a
    restart)
418b70b
        $1
418b70b
        ;;
bdea17a
    reload)
418b70b
        rh_status_q || exit 7
418b70b
        $1
418b70b
        ;;
418b70b
    force-reload)
418b70b
        force_reload
418b70b
        ;;
bdea17a
    status)
418b70b
        rh_status
418b70b
        ;;
418b70b
    condrestart|try-restart)
418b70b
        rh_status_q || exit 0
418b70b
        restart
418b70b
        ;;
bdea17a
    *)
418b70b
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
418b70b
        exit 2
bdea17a
esac
418b70b
exit $?
bdea17a