2004-10-18 12:21:41 +00:00
|
|
|
#!/bin/bash
|
2004-09-09 10:35:48 +00:00
|
|
|
#
|
|
|
|
# postfix Postfix Mail Transfer Agent
|
|
|
|
#
|
2007-06-14 13:27:32 +00:00
|
|
|
# chkconfig: - 80 30
|
2004-09-09 10:35:48 +00:00
|
|
|
# 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.
|
|
|
|
|
2007-10-04 13:39:00 +00:00
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: postfix MTA
|
|
|
|
# Required-Start: $local_fs $network $remote_fs
|
|
|
|
# Required-Stop: $local_fs $network $remote_fs
|
|
|
|
# Short-Description: start and stop postfix
|
|
|
|
# Description: Postfix is a Mail Transport Agent, which is the program that
|
|
|
|
# moves mail from one machine to another.
|
|
|
|
### END INIT INFO
|
|
|
|
|
2004-09-09 10:35:48 +00:00
|
|
|
# Source function library.
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
|
|
|
|
# Source networking configuration.
|
|
|
|
. /etc/sysconfig/network
|
|
|
|
|
|
|
|
RETVAL=0
|
2005-11-11 14:06:11 +00:00
|
|
|
prog="postfix"
|
2004-09-09 10:35:48 +00:00
|
|
|
|
2009-01-22 15:53:45 +00:00
|
|
|
ALIASESDB_STAMP=/var/lib/misc/postfix.aliasesdb-stamp
|
|
|
|
|
2007-10-04 13:39:00 +00:00
|
|
|
status master >/dev/null 2>&1
|
|
|
|
running=$?
|
|
|
|
|
|
|
|
conf_check() {
|
|
|
|
[ -x /usr/sbin/postfix ] || exit 5
|
|
|
|
[ -d /etc/postfix ] || exit 6
|
|
|
|
[ -d /var/spool/postfix ] || exit 5
|
|
|
|
}
|
|
|
|
|
2009-01-22 15:53:45 +00:00
|
|
|
make_aliasesdb() {
|
|
|
|
if [ "$(/usr/sbin/postconf -h alias_database)" == "hash:/etc/aliases" ]
|
|
|
|
then
|
|
|
|
# /etc/aliases.db may be used by other MTA, make sure nothing
|
|
|
|
# has touched it since our last newaliases call
|
|
|
|
[ /etc/aliases -nt /etc/aliases.db ] ||
|
|
|
|
[ "$ALIASESDB_STAMP" -nt /etc/aliases.db ] ||
|
|
|
|
[ "$ALIASESDB_STAMP" -ot /etc/aliases.db ] || return
|
|
|
|
/usr/bin/newaliases
|
|
|
|
touch -r /etc/aliases.db "$ALIASESDB_STAMP"
|
|
|
|
else
|
|
|
|
/usr/bin/newaliases
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2004-09-09 10:35:48 +00:00
|
|
|
start() {
|
2007-10-04 13:39:00 +00:00
|
|
|
# Check that networking is up.
|
|
|
|
[ ${NETWORKING} = "no" ] && exit 1
|
|
|
|
conf_check
|
2004-09-09 10:35:48 +00:00
|
|
|
# Start daemons.
|
2005-03-18 14:07:24 +00:00
|
|
|
echo -n $"Starting postfix: "
|
2009-01-22 15:53:45 +00:00
|
|
|
make_aliasesdb >/dev/null 2>&1
|
2005-11-11 14:06:11 +00:00
|
|
|
/usr/sbin/postfix start 2>/dev/null 1>&2 && success || failure $"$prog start"
|
2004-09-09 10:35:48 +00:00
|
|
|
RETVAL=$?
|
|
|
|
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/postfix
|
|
|
|
echo
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
2007-10-04 13:39:00 +00:00
|
|
|
conf_check
|
2004-09-09 10:35:48 +00:00
|
|
|
# Stop daemons.
|
2005-03-18 14:07:24 +00:00
|
|
|
echo -n $"Shutting down postfix: "
|
2005-11-11 14:06:11 +00:00
|
|
|
/usr/sbin/postfix stop 2>/dev/null 1>&2 && success || failure $"$prog stop"
|
2004-09-09 10:35:48 +00:00
|
|
|
RETVAL=$?
|
|
|
|
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/postfix
|
|
|
|
echo
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
reload() {
|
2007-10-04 13:39:00 +00:00
|
|
|
conf_check
|
2005-03-18 14:07:24 +00:00
|
|
|
echo -n $"Reloading postfix: "
|
2005-11-11 14:06:11 +00:00
|
|
|
/usr/sbin/postfix reload 2>/dev/null 1>&2 && success || failure $"$prog reload"
|
2004-09-09 10:35:48 +00:00
|
|
|
RETVAL=$?
|
|
|
|
echo
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
abort() {
|
2007-10-04 13:39:00 +00:00
|
|
|
conf_check
|
2005-11-11 14:06:11 +00:00
|
|
|
/usr/sbin/postfix abort 2>/dev/null 1>&2 && success || failure $"$prog abort"
|
2004-09-09 10:35:48 +00:00
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
flush() {
|
2007-10-04 13:39:00 +00:00
|
|
|
conf_check
|
2005-11-11 14:06:11 +00:00
|
|
|
/usr/sbin/postfix flush 2>/dev/null 1>&2 && success || failure $"$prog flush"
|
2004-09-09 10:35:48 +00:00
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
check() {
|
2007-10-04 13:39:00 +00:00
|
|
|
conf_check
|
2005-11-11 14:06:11 +00:00
|
|
|
/usr/sbin/postfix check 2>/dev/null 1>&2 && success || failure $"$prog check"
|
2004-09-09 10:35:48 +00:00
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
# See how we were called.
|
|
|
|
case "$1" in
|
|
|
|
start)
|
2007-10-04 13:39:00 +00:00
|
|
|
[ $running -eq 0 ] && exit 0
|
2004-09-09 10:35:48 +00:00
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
2007-10-04 13:39:00 +00:00
|
|
|
[ $running -eq 0 ] || exit 0
|
2004-09-09 10:35:48 +00:00
|
|
|
stop
|
|
|
|
;;
|
2007-10-04 13:39:00 +00:00
|
|
|
restart|force-reload)
|
2004-09-09 10:35:48 +00:00
|
|
|
stop
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
reload)
|
2007-10-04 13:39:00 +00:00
|
|
|
[ $running -eq 0 ] || exit 7
|
2004-09-09 10:35:48 +00:00
|
|
|
reload
|
|
|
|
;;
|
|
|
|
abort)
|
|
|
|
abort
|
|
|
|
;;
|
|
|
|
flush)
|
|
|
|
flush
|
|
|
|
;;
|
|
|
|
check)
|
|
|
|
check
|
|
|
|
;;
|
|
|
|
status)
|
|
|
|
status master
|
|
|
|
;;
|
|
|
|
condrestart)
|
2007-10-04 13:39:00 +00:00
|
|
|
[ $running -eq 0 ] || exit 0
|
|
|
|
stop
|
|
|
|
start
|
2004-09-09 10:35:48 +00:00
|
|
|
;;
|
|
|
|
*)
|
2005-11-11 14:06:11 +00:00
|
|
|
echo $"Usage: $0 {start|stop|restart|reload|abort|flush|check|status|condrestart}"
|
2007-10-04 13:39:00 +00:00
|
|
|
exit 2
|
2004-09-09 10:35:48 +00:00
|
|
|
esac
|
|
|
|
|
|
|
|
exit $?
|