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

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