]>
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 | |
fe023abb | 77 | daemon /usr/sbin/postfix reload |
4f3faccd | 78 | RETVAL=$? |
13f423a4 | 79 | [ $RETVAL -ne 0 ] && RETVAL=7 |
4f3faccd | 80 | else |
1acd8d56 | 81 | msg_not_running Postfix |
13f423a4 | 82 | exit 7 |
4f3faccd | 83 | fi |
a281e397 AM |
84 | ;; |
85 | status) | |
405661d4 | 86 | status master |
00063a89 | 87 | exit $? |
a281e397 AM |
88 | ;; |
89 | rebuilddb) | |
4f3faccd | 90 | standard_db="access canonical relocated transport virtual" |
603402cb | 91 | extra_db=$(ls -1 /etc/mail/*.db 2> /dev/null | grep -v aliases.db | sed -e 's#.db$##') |
2479a467 | 92 | for base in $standard_db $extra_db; do |
4f3faccd | 93 | I=$(basename "$base") |
cbbc0845 | 94 | if [ -f /etc/mail/$I ]; then |
563bd3a0 | 95 | /usr/sbin/postmap hash:/etc/mail/$I < /etc/mail/$I |
96 | fi | |
a281e397 | 97 | done |
603402cb | 98 | /usr/bin/newaliases |
4f3faccd | 99 | ;; |
a281e397 | 100 | *) |
13f423a4 | 101 | msg_usage "$0 {start|stop|restart|reload|force-reload|rebuilddb|status}" |
102 | exit 3 | |
a281e397 AM |
103 | esac |
104 | ||
00063a89 | 105 | exit $RETVAL |