]>
Commit | Line | Data |
---|---|---|
a281e397 AM |
1 | #!/bin/sh |
2 | # | |
4f3faccd | 3 | # postfix This shell script takes care of starting and stopping |
4 | # postfix. | |
a281e397 | 5 | # |
6a599ba3 | 6 | # chkconfig: 345 80 30 |
563bd3a0 | 7 | # |
f2a36c02 | 8 | # description: Postfix is a Mail Transport Agent, which is the program \ |
563bd3a0 | 9 | # that moves mail from one machine to another. |
10 | ||
a281e397 | 11 | |
563bd3a0 | 12 | # Source function library |
a281e397 AM |
13 | . /etc/rc.d/init.d/functions |
14 | ||
563bd3a0 | 15 | # Get network config |
a281e397 AM |
16 | . /etc/sysconfig/network |
17 | ||
563bd3a0 | 18 | # Get service config |
19 | [ -f /etc/sysconfig/postfix ] && . /etc/sysconfig/postfix | |
20 | ||
d2efe7d5 | 21 | # Check that networking is up. |
4f3faccd | 22 | if is_yes "${NETWORKING}"; then |
ceec68da | 23 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then |
4f3faccd | 24 | msg_network_down Postfix |
25 | exit 1 | |
26 | fi | |
27 | else | |
28 | exit 0 | |
d2efe7d5 | 29 | fi |
30 | ||
13f423a4 | 31 | RETVAL=0 |
a281e397 AM |
32 | # See how we were called. |
33 | case "$1" in | |
34 | start) | |
563bd3a0 | 35 | # Check if the service is already running? |
36 | if [ ! -f /var/lock/subsys/postfix ]; then | |
00063a89 | 37 | msg_starting Postfix |
563bd3a0 | 38 | busy |
9e5ab0fc | 39 | MSG="`/usr/sbin/postfix start 2>&1`" |
cbbc0845 | 40 | if [ $? -eq 0 ]; then |
4f3faccd | 41 | ok |
00063a89 | 42 | touch /var/lock/subsys/postfix |
563bd3a0 | 43 | else |
13f423a4 | 44 | RETVAL=1 |
4f3faccd | 45 | fail |
9e5ab0fc | 46 | echo "$MSG" |
563bd3a0 | 47 | fi |
a281e397 | 48 | else |
f08ea5b1 | 49 | msg_already_running Postfix |
a281e397 | 50 | fi |
a281e397 AM |
51 | ;; |
52 | stop) | |
53 | # Stop daemons. | |
4f3faccd | 54 | if [ -f /var/lock/subsys/postfix ]; then |
55 | msg_stopping Postfix | |
00063a89 | 56 | busy |
57 | MSG="`/usr/sbin/postfix stop 2>&1`" | |
13f423a4 | 58 | if [ $? -eq 0 ]; then |
4f3faccd | 59 | ok |
00063a89 | 60 | else |
4f3faccd | 61 | fail |
00063a89 | 62 | echo "$MSG" |
63 | fi | |
64 | rm -f /var/lock/subsys/postfix | |
4f3faccd | 65 | else |
66 | msg_not_running Postfix | |
a281e397 | 67 | fi |
a281e397 AM |
68 | ;; |
69 | restart) | |
70 | $0 stop | |
71 | $0 start | |
13f423a4 | 72 | exit $? |
a281e397 | 73 | ;; |
13f423a4 | 74 | reload|force-reload) |
4f3faccd | 75 | if [ -f /var/lock/subsys/postfix ]; then |
76 | msg_reloading Postfix | |
77 | busy | |
78 | /usr/sbin/postfix reload | |
79 | RETVAL=$? | |
13f423a4 | 80 | [ $RETVAL -ne 0 ] && RETVAL=7 |
4f3faccd | 81 | [ $RETVAL -eq 0 ] && ok || died |
82 | else | |
13f423a4 | 83 | msg_not_running Postfix >&2 |
84 | exit 7 | |
4f3faccd | 85 | fi |
a281e397 AM |
86 | ;; |
87 | status) | |
405661d4 | 88 | status master |
00063a89 | 89 | exit $? |
a281e397 AM |
90 | ;; |
91 | rebuilddb) | |
4f3faccd | 92 | standard_db="access canonical relocated transport virtual" |
603402cb | 93 | extra_db=$(ls -1 /etc/mail/*.db 2> /dev/null | grep -v aliases.db | sed -e 's#.db$##') |
2479a467 | 94 | for base in $standard_db $extra_db; do |
4f3faccd | 95 | I=$(basename "$base") |
cbbc0845 | 96 | if [ -f /etc/mail/$I ]; then |
563bd3a0 | 97 | /usr/sbin/postmap hash:/etc/mail/$I < /etc/mail/$I |
98 | fi | |
a281e397 | 99 | done |
603402cb | 100 | /usr/bin/newaliases |
4f3faccd | 101 | ;; |
a281e397 | 102 | *) |
13f423a4 | 103 | msg_usage "$0 {start|stop|restart|reload|force-reload|rebuilddb|status}" |
104 | exit 3 | |
a281e397 AM |
105 | esac |
106 | ||
00063a89 | 107 | exit $RETVAL |