Blame SOURCES/postfix-etc-init.d-postfix

962864
#!/bin/bash
962864
#
962864
# postfix      Postfix Mail Transfer Agent
962864
#
962864
# chkconfig: - 80 30
962864
# description: Postfix is a Mail Transport Agent, which is the program \
962864
#              that moves mail from one machine to another.
962864
# processname: master
962864
# pidfile: /var/spool/postfix/pid/master.pid
962864
# config: /etc/postfix/main.cf
962864
# config: /etc/postfix/master.cf
962864
#
962864
# Based on startup script from Simon J Mudd <sjmudd@pobox.com>
962864
# 25/02/99: Mostly s/sendmail/postfix/g by John A. Martin <jam@jamux.com>
962864
# 23/11/00: Changes & suggestions by Ajay Ramaswamy <ajayr@bigfoot.com>
962864
# 20/01/01: Changes to fall in line with RedHat 7.0 style
962864
# 23/02/01: Fix a few untidy problems with help from Daniel Roesen.
962864
962864
### BEGIN INIT INFO
962864
# Provides: postfix $mail-transfer-agent
962864
# Required-Start: $local_fs $network $remote_fs
962864
# Required-Stop: $local_fs $network $remote_fs
962864
# Short-Description: start and stop postfix
962864
# Description: Postfix is a Mail Transport Agent, which is the program that 
962864
#              moves mail from one machine to another.
962864
### END INIT INFO
962864
962864
# Source function library.
962864
. /etc/rc.d/init.d/functions
962864
962864
# Source networking configuration.
962864
. /etc/sysconfig/network
962864
962864
RETVAL=0
962864
prog="postfix"
962864
lockfile=/var/lock/subsys/$prog
962864
pidfile=/var/spool/postfix/pid/master.pid
962864
962864
ALIASESDB_STAMP=/var/lib/misc/postfix.aliasesdb-stamp
962864
962864
# Script to update chroot environment
962864
CHROOT_UPDATE=/etc/postfix/chroot-update
962864
962864
status -p $pidfile -l $(basename $lockfile) master >/dev/null 2>&1
962864
running=$?
962864
962864
conf_check() {
962864
    [ -x /usr/sbin/postfix ] || exit 5
962864
    [ -d /etc/postfix ] || exit 6
962864
    [ -d /var/spool/postfix ] || exit 5
962864
}
962864
962864
make_aliasesdb() {
962864
	if [ "$(/usr/sbin/postconf -h alias_database)" == "hash:/etc/aliases" ]
962864
	then
962864
		# /etc/aliases.db may be used by other MTA, make sure nothing
962864
		# has touched it since our last newaliases call
962864
		[ /etc/aliases -nt /etc/aliases.db ] ||
962864
			[ "$ALIASESDB_STAMP" -nt /etc/aliases.db ] ||
962864
			[ "$ALIASESDB_STAMP" -ot /etc/aliases.db ] || return
962864
		/usr/bin/newaliases
962864
		touch -r /etc/aliases.db "$ALIASESDB_STAMP"
962864
	else
962864
		/usr/bin/newaliases
962864
	fi
962864
}
962864
962864
start() {
962864
	[ "$EUID" != "0" ] && exit 4
962864
	# Check that networking is up.
962864
	[ ${NETWORKING} = "no" ] && exit 1
962864
	conf_check
962864
	# Start daemons.
962864
	echo -n $"Starting postfix: "
962864
	make_aliasesdb >/dev/null 2>&1
962864
	[ -x $CHROOT_UPDATE ] && $CHROOT_UPDATE
962864
	/usr/sbin/postfix start 2>/dev/null 1>&2 && success || failure $"$prog start"
962864
	RETVAL=$?
962864
	[ $RETVAL -eq 0 ] && touch $lockfile
962864
        echo
962864
	return $RETVAL
962864
}
962864
962864
stop() {
962864
	[ "$EUID" != "0" ] && exit 4
962864
	conf_check
962864
        # Stop daemons.
962864
	echo -n $"Shutting down postfix: "
962864
	/usr/sbin/postfix stop 2>/dev/null 1>&2 && success || failure $"$prog stop"
962864
	RETVAL=$?
962864
	[ $RETVAL -eq 0 ] && rm -f $lockfile $pidfile
962864
	echo
962864
	return $RETVAL
962864
}
962864
962864
reload() {
962864
	conf_check
962864
	echo -n $"Reloading postfix: "
962864
	[ -x $CHROOT_UPDATE ] && $CHROOT_UPDATE
962864
	/usr/sbin/postfix reload 2>/dev/null 1>&2 && success || failure $"$prog reload"
962864
	RETVAL=$?
962864
	echo
962864
	return $RETVAL
962864
}
962864
962864
abort() {
962864
	conf_check
962864
	/usr/sbin/postfix abort 2>/dev/null 1>&2 && success || failure $"$prog abort"
962864
	return $?
962864
}
962864
962864
flush() {
962864
	conf_check
962864
	/usr/sbin/postfix flush 2>/dev/null 1>&2 && success || failure $"$prog flush"
962864
	return $?
962864
}
962864
962864
check() {
962864
	conf_check
962864
	/usr/sbin/postfix check 2>/dev/null 1>&2 && success || failure $"$prog check"
962864
	return $?
962864
}
962864
962864
# See how we were called.
962864
case "$1" in
962864
  start)
962864
	[ $running -eq 0 ] && exit 0
962864
	start
962864
	;;
962864
  stop)
962864
	[ $running -eq 0 ] || exit 0
962864
	stop
962864
	;;
962864
  restart|force-reload)
962864
	stop
962864
	start
962864
	;;
962864
  reload)
962864
	[ $running -eq 0 ] || exit 7
962864
	reload
962864
	;;
962864
  abort)
962864
	abort
962864
	;;
962864
  flush)
962864
	flush
962864
	;;
962864
  check)
962864
	check
962864
	;;
962864
  status)
962864
  	status -p $pidfile -l $(basename $lockfile) master
962864
	;;
962864
  condrestart)
962864
	[ $running -eq 0 ] || exit 0
962864
	stop
962864
	start
962864
	;;
962864
  *)
962864
	echo $"Usage: $0 {start|stop|restart|reload|abort|flush|check|status|condrestart}"
962864
	exit 2
962864
esac
962864
962864
exit $?