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