]>
Commit | Line | Data |
---|---|---|
a281e397 AM |
1 | #!/bin/sh |
2 | # | |
3 | # postfix This shell script takes care of starting and stopping | |
4 | # postfix. | |
5 | # | |
563bd3a0 | 6 | # chkconfig: 2345 80 30 |
7 | # | |
8 | # description: Postfix is a Mail Transport Agent, which is the program | |
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. |
00063a89 | 22 | if is_no "${NETWORKING}"; then |
23 | msg_Network_Down Postfix | |
24 | exit 1 | |
d2efe7d5 | 25 | fi |
26 | ||
a281e397 AM |
27 | # See how we were called. |
28 | case "$1" in | |
29 | start) | |
563bd3a0 | 30 | # Check if the service is already running? |
31 | if [ ! -f /var/lock/subsys/postfix ]; then | |
00063a89 | 32 | msg_starting Postfix |
563bd3a0 | 33 | busy |
34 | newaliases | |
35 | $0 rebuilddb | |
9e5ab0fc AF |
36 | MSG="`/usr/sbin/postfix start 2>&1`" |
37 | if [ "$?" = "0" ] ; then | |
563bd3a0 | 38 | deltext; ok |
00063a89 | 39 | touch /var/lock/subsys/postfix |
563bd3a0 | 40 | else |
320b372d | 41 | deltext; fail |
9e5ab0fc | 42 | echo "$MSG" |
563bd3a0 | 43 | fi |
a281e397 | 44 | else |
00063a89 | 45 | msg_Already_Running Postfix |
a281e397 | 46 | fi |
a281e397 AM |
47 | ;; |
48 | stop) | |
49 | # Stop daemons. | |
00063a89 | 50 | if [ -f /var/lock/subsys/postfix ]; then |
51 | msg_stopping Postfix | |
52 | busy | |
53 | MSG="`/usr/sbin/postfix stop 2>&1`" | |
54 | if [ "$?" = "0" ]; then | |
55 | deltext; ok | |
56 | else | |
57 | deltext; fail | |
58 | echo "$MSG" | |
59 | fi | |
60 | rm -f /var/lock/subsys/postfix | |
61 | else | |
62 | msg_Not_Running Postfix | |
63 | exit 1 | |
a281e397 | 64 | fi |
a281e397 AM |
65 | ;; |
66 | restart) | |
67 | $0 stop | |
68 | $0 start | |
69 | ;; | |
70 | reload) | |
71 | /usr/sbin/postfix reload | |
72 | ;; | |
73 | status) | |
405661d4 | 74 | status master |
00063a89 | 75 | exit $? |
a281e397 AM |
76 | ;; |
77 | rebuilddb) | |
2479a467 AM |
78 | standard_db="access canonical relocated transport virtual" |
79 | extra_db=$(ls -1 /etc/mail/*.db 2> /dev/null | sed -e 's#.db$##') | |
80 | for base in $standard_db $extra_db; do | |
81 | I=$(basename "$base") | |
563bd3a0 | 82 | if [ -f /etc/mail/$I ] ; then |
83 | /usr/sbin/postmap hash:/etc/mail/$I < /etc/mail/$I | |
84 | fi | |
a281e397 AM |
85 | done |
86 | ;; | |
87 | *) | |
00063a89 | 88 | msg_Usage "$0 {start|stop|status|restart|reload|rebuilddb}" |
a281e397 AM |
89 | exit 1 |
90 | esac | |
91 | ||
00063a89 | 92 | exit $RETVAL |