Subversion Repositories configs

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 - 1
#!/bin/bash
2
#
3
# postfix      Postfix Mail Transfer Agent
4
#
5
# chkconfig: 2345 80 30
6
# description: Postfix is a Mail Transport Agent, which is the program \
7
#              that moves mail from one machine to another.
8
# processname: master
9
# pidfile: /var/spool/postfix/pid/master.pid
10
# config: /etc/postfix/main.cf
11
# config: /etc/postfix/master.cf
12
#
13
# Based on startup script from Simon J Mudd <sjmudd@pobox.com>
14
# 25/02/99: Mostly s/sendmail/postfix/g by John A. Martin <jam@jamux.com>
15
# 23/11/00: Changes & suggestions by Ajay Ramaswamy <ajayr@bigfoot.com>
16
# 20/01/01: Changes to fall in line with RedHat 7.0 style
17
# 23/02/01: Fix a few untidy problems with help from Daniel Roesen.
18
 
19
### BEGIN INIT INFO
20
# Provides: postfix MTA
21
# Required-Start: $local_fs $network $remote_fs
22
# Required-Stop: $local_fs $network $remote_fs
23
# Default-Start: 2 3 4 5
24
# Default-Stop: 0 1 6
25
# Short-Description: start and stop postfix
26
# Description: Postfix is a Mail Transport Agent, which is the program that
27
#              moves mail from one machine to another.
28
### END INIT INFO
29
 
30
# Source function library.
31
. /etc/rc.d/init.d/functions
32
 
33
# Source networking configuration.
34
. /etc/sysconfig/network
35
 
36
RETVAL=0
37
prog="postfix"
38
lockfile=/var/lock/subsys/$prog
39
pidfile=/var/spool/postfix/pid/master.pid
40
 
41
ALIASESDB_STAMP=/var/lib/misc/postfix.aliasesdb-stamp
42
 
43
# Script to update chroot environment
44
CHROOT_UPDATE=/etc/postfix/chroot-update
45
 
46
status -p $pidfile -l $(basename $lockfile) -b /usr/libexec/postfix/master master >/dev/null 2>&1
47
running=$?
48
 
49
conf_check() {
50
    [ -x /usr/sbin/postfix ] || exit 5
51
    [ -d /etc/postfix ] || exit 6
52
    [ -d /var/spool/postfix ] || exit 5
53
}
54
 
55
make_aliasesdb() {
56
	if [ "$(/usr/sbin/postconf -h alias_database)" == "hash:/etc/aliases" ]
57
	then
58
		# /etc/aliases.db may be used by other MTA, make sure nothing
59
		# has touched it since our last newaliases call
60
		[ /etc/aliases -nt /etc/aliases.db ] ||
61
			[ "$ALIASESDB_STAMP" -nt /etc/aliases.db ] ||
62
			[ "$ALIASESDB_STAMP" -ot /etc/aliases.db ] || return
63
		/usr/bin/newaliases
64
		touch -r /etc/aliases.db "$ALIASESDB_STAMP"
65
	else
66
		/usr/bin/newaliases
67
	fi
68
}
69
 
70
start() {
71
	[ "$EUID" != "0" ] && exit 4
72
	# Check that networking is up.
73
	[ ${NETWORKING} = "no" ] && exit 1
74
	conf_check
75
	# Start daemons.
76
	echo -n $"Starting postfix: "
77
	make_aliasesdb >/dev/null 2>&1
78
	[ -x $CHROOT_UPDATE ] && $CHROOT_UPDATE
79
	/usr/sbin/postfix start 2>/dev/null 1>&2 && success || failure $"$prog start"
80
	RETVAL=$?
81
	[ $RETVAL -eq 0 ] && touch $lockfile
82
        echo
83
	return $RETVAL
84
}
85
 
86
stop() {
87
	[ "$EUID" != "0" ] && exit 4
88
	conf_check
89
        # Stop daemons.
90
	echo -n $"Shutting down postfix: "
91
	/usr/sbin/postfix stop 2>/dev/null 1>&2 && success || failure $"$prog stop"
92
	RETVAL=$?
93
	[ $RETVAL -eq 0 ] && rm -f $lockfile $pidfile
94
	echo
95
	return $RETVAL
96
}
97
 
98
reload() {
99
	conf_check
100
	echo -n $"Reloading postfix: "
101
	[ -x $CHROOT_UPDATE ] && $CHROOT_UPDATE
102
	/usr/sbin/postfix reload 2>/dev/null 1>&2 && success || failure $"$prog reload"
103
	RETVAL=$?
104
	echo
105
	return $RETVAL
106
}
107
 
108
abort() {
109
	conf_check
110
	/usr/sbin/postfix abort 2>/dev/null 1>&2 && success || failure $"$prog abort"
111
	return $?
112
}
113
 
114
flush() {
115
	conf_check
116
	/usr/sbin/postfix flush 2>/dev/null 1>&2 && success || failure $"$prog flush"
117
	return $?
118
}
119
 
120
check() {
121
	conf_check
122
	/usr/sbin/postfix check 2>/dev/null 1>&2 && success || failure $"$prog check"
123
	return $?
124
}
125
 
126
# See how we were called.
127
case "$1" in
128
  start)
129
	[ $running -eq 0 ] && exit 0
130
	start
131
	;;
132
  stop)
133
	[ $running -eq 0 ] || exit 0
134
	stop
135
	;;
136
  restart|force-reload)
137
	stop
138
	start
139
	;;
140
  reload)
141
	[ $running -eq 0 ] || exit 7
142
	reload
143
	;;
144
  abort)
145
	abort
146
	;;
147
  flush)
148
	flush
149
	;;
150
  check)
151
	check
152
	;;
153
  status)
154
	status -p $pidfile -l $(basename $lockfile) -b /usr/libexec/postfix/master master
155
	;;
156
  condrestart)
157
	[ $running -eq 0 ] || exit 0
158
	stop
159
	start
160
	;;
161
  *)
162
	echo $"Usage: $0 {start|stop|restart|reload|abort|flush|check|status|condrestart}"
163
	exit 2
164
esac
165
 
166
exit $?