#!/bin/sh
#
# postfix      This shell script takes care of starting and stopping
#               postfix.
#
# chkconfig: 2345 80 30
# description: Postfix is a Mail Transport Agent, which is the program \
#              that moves mail from one machine to another.
# processname: postfix
# config: /etc/postfix/
# pidfile: /var/run/postfix.pid

# Hacked by jam 25 Feb 99.  Mostly s/sendmail/postfix/g :-)
# Rewritten to match current Red Hat standards by bero, Jan 23 2001

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

# Source networking configuration.
test -f /etc/sysconfig/network && . /etc/sysconfig/network

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

postfix=/usr/sbin/postfix
prog=postfix

start() {
    action $"Starting $prog:" $postfix start
    RETVAL=$?
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/postfix
}

stop() {
    action $"Stopping $prog:" $postfix stop
    RETVAL=$?
    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/postfix
}

RETVAL=0

# See how we were called.
case "$1" in
    start)
        # Start daemons.
        start
        ;;
    stop)
        # Stop daemons.
        stop
        ;;
    restart)
        stop
        start
        ;;
    condrestart)
        if [ -f /var/lock/subsys/postfix ]; then
            stop
            start
        fi
        ;;
    reload)
        action $"Reloading $prog:" $postfix reload
        exit $?
        ;;
    abort)
        action $"Aborting $prog:" $postfix abort
        exit $?
        ;;
    flush)
        action $"Flushing $prog queue:" $postfix flush
        exit $?
        ;;
    check)
        action $"Checking $prog:" $postfix check
        exit $?
        ;;
    status)
        status master
        echo
        status pickup
        echo
        status qmgr
        RETVAL=$?
        echo
        ;;
    *)
        echo $"Usage: $prog {start|stop|restart|reload|condrestart|abort|flush|check|status}"
        exit 1
esac

exit $RETVAL
