2004-10-18 12:21:41 +00:00
|
|
|
#!/bin/bash
|
2004-09-09 10:35:48 +00:00
|
|
|
#
|
|
|
|
# postfix Postfix Mail Transfer Agent
|
|
|
|
#
|
|
|
|
# chkconfig: 2345 80 30
|
|
|
|
# description: Postfix is a Mail Transport Agent, which is the program \
|
|
|
|
# that moves mail from one machine to another.
|
|
|
|
# processname: master
|
|
|
|
# pidfile: /var/spool/postfix/pid/master.pid
|
|
|
|
# config: /etc/postfix/main.cf
|
|
|
|
# config: /etc/postfix/master.cf
|
|
|
|
#
|
2004-09-09 10:35:52 +00:00
|
|
|
# Based on startup script from Simon J Mudd <sjmudd@pobox.com>
|
2004-09-09 10:35:48 +00:00
|
|
|
# 25/02/99: Mostly s/sendmail/postfix/g by John A. Martin <jam@jamux.com>
|
|
|
|
# 23/11/00: Changes & suggestions by Ajay Ramaswamy <ajayr@bigfoot.com>
|
|
|
|
# 20/01/01: Changes to fall in line with RedHat 7.0 style
|
|
|
|
# 23/02/01: Fix a few untidy problems with help from Daniel Roesen.
|
|
|
|
|
|
|
|
# Source function library.
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
|
|
|
|
# Source networking configuration.
|
|
|
|
. /etc/sysconfig/network
|
|
|
|
|
|
|
|
# Check that networking is up.
|
|
|
|
[ ${NETWORKING} = "no" ] && exit 0
|
|
|
|
|
|
|
|
[ -x /usr/sbin/postfix ] || exit 0
|
|
|
|
[ -d /etc/postfix ] || exit 0
|
|
|
|
[ -d /var/spool/postfix ] || exit 0
|
|
|
|
|
|
|
|
RETVAL=0
|
|
|
|
|
|
|
|
start() {
|
|
|
|
# Start daemons.
|
2005-03-18 14:07:24 +00:00
|
|
|
echo -n $"Starting postfix: "
|
2004-10-18 12:21:41 +00:00
|
|
|
alias_database=$(postconf -h alias_database 2>/dev/null)
|
|
|
|
RETVAL=$?
|
2005-03-18 14:07:24 +00:00
|
|
|
if [ $RETVAL -ne 0 ]; then
|
|
|
|
failure $"determination of alias_database"
|
2004-10-18 12:21:41 +00:00
|
|
|
echo
|
2005-03-18 14:07:24 +00:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
if [ -n "$alias_database" ]; then
|
|
|
|
/usr/sbin/postalias ${alias_database//,} 2>/dev/null
|
|
|
|
RETVAL=$?
|
|
|
|
if [ $RETVAL -ne 0 ]; then
|
|
|
|
failure $"postalias $alias_database"
|
|
|
|
echo
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
/usr/sbin/postfix start 2>/dev/null 1>&2 && success || failure $"postfix start"
|
2004-09-09 10:35:48 +00:00
|
|
|
RETVAL=$?
|
|
|
|
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/postfix
|
|
|
|
echo
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
# Stop daemons.
|
2005-03-18 14:07:24 +00:00
|
|
|
echo -n $"Shutting down postfix: "
|
|
|
|
/usr/sbin/postfix stop 2>/dev/null 1>&2 && success || failure $"postfix stop"
|
2004-09-09 10:35:48 +00:00
|
|
|
RETVAL=$?
|
|
|
|
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/postfix
|
|
|
|
echo
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
reload() {
|
2005-03-18 14:07:24 +00:00
|
|
|
echo -n $"Reloading postfix: "
|
|
|
|
/usr/sbin/postfix reload 2>/dev/null 1>&2 && success || failure $"postfix reload"
|
2004-09-09 10:35:48 +00:00
|
|
|
RETVAL=$?
|
|
|
|
echo
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
abort() {
|
2005-03-18 14:07:24 +00:00
|
|
|
/usr/sbin/postfix abort 2>/dev/null 1>&2 && success || failure $"postfix abort"
|
2004-09-09 10:35:48 +00:00
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
flush() {
|
2005-03-18 14:07:24 +00:00
|
|
|
/usr/sbin/postfix flush 2>/dev/null 1>&2 && success || failure $"postfix flush"
|
2004-09-09 10:35:48 +00:00
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
check() {
|
2005-03-18 14:07:24 +00:00
|
|
|
/usr/sbin/postfix check 2>/dev/null 1>&2 && success || failure $"postfix check"
|
2004-09-09 10:35:48 +00:00
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
2004-09-09 10:35:52 +00:00
|
|
|
restart() {
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
}
|
|
|
|
|
2004-09-09 10:35:48 +00:00
|
|
|
# See how we were called.
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
reload)
|
|
|
|
reload
|
|
|
|
;;
|
|
|
|
abort)
|
|
|
|
abort
|
|
|
|
;;
|
|
|
|
flush)
|
|
|
|
flush
|
|
|
|
;;
|
|
|
|
check)
|
|
|
|
check
|
|
|
|
;;
|
|
|
|
status)
|
|
|
|
status master
|
|
|
|
;;
|
|
|
|
condrestart)
|
|
|
|
[ -f /var/lock/subsys/postfix ] && restart || :
|
|
|
|
;;
|
|
|
|
*)
|
2005-03-18 14:07:24 +00:00
|
|
|
echo $"Usage: postfix {start|stop|restart|reload|abort|flush|check|status|condrestart}"
|
2004-09-09 10:35:48 +00:00
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit $?
|