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