]> git.pld-linux.org Git - packages/postfix.git/blob - postfix.init
- fix start+stop=100
[packages/postfix.git] / postfix.init
1 #!/bin/sh
2 #
3 # postfix       This shell script takes care of starting and stopping
4 #               postfix.
5 #
6 # chkconfig:    345 80 20
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 networking_check() {
23         if is_yes "${NETWORKING}"; then
24                 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
25                         msg_network_down "Postfix"
26                         exit 1
27                 fi
28         else
29                 exit 0
30         fi
31 }
32
33 start() {
34         local msg
35
36         if [ ! -f /var/lock/subsys/postfix ]; then
37                 msg_starting "Postfix"
38                 busy
39                 msg=$(/usr/sbin/postfix start 2>&1)
40                 RETVAL=$?
41                 if [ $RETVAL -eq 0 ]; then
42                         ok
43                         touch /var/lock/subsys/postfix
44                 else
45                         fail
46                         echo >&2 "$msg"
47                 fi
48         else
49                 msg_already_running "Postfix"
50         fi
51 }
52
53 stop() {
54         local msg
55         if [ -f /var/lock/subsys/postfix ]; then
56                 msg_stopping "Postfix"
57                 busy
58                 msg=$(/usr/sbin/postfix stop 2>&1)
59                 if [ $? -eq 0 ]; then
60                         ok
61                 else
62                         fail
63                         echo >&2 "$msg"
64                 fi
65                 rm -f /var/lock/subsys/postfix
66         else
67                 msg_not_running "Postfix"
68         fi
69 }
70
71 reload() {
72         local msg
73         if [ -f /var/lock/subsys/postfix ]; then
74                 msg_reloading "Postfix"
75                 busy
76                 msg=$(/usr/sbin/postfix reload 2>&1)
77                 RETVAL=$?
78                 [ $RETVAL -ne 0 ] && RETVAL=7
79         else
80                 msg_not_running "Postfix"
81                 RETVAL=7
82         fi
83 }
84
85 RETVAL=0
86 # See how we were called.
87 case "$1" in
88   start)
89         networking_check
90         start
91         ;;
92   stop)
93         stop
94         ;;
95   restart)
96         networking_check
97         stop
98         start
99         ;;
100   reload|force-reload)
101         networking_check
102         reload
103         ;;
104   rebuilddb)
105         standard_db="access canonical relocated transport virtual"
106         extra_db=$(ls -1 /etc/mail/*.db 2> /dev/null | egrep -v '/(access|canonical|relocated|transport|virtual|aliases)\.db$')
107
108         echo -n "Rebuilding databases: "
109         for base in $standard_db $extra_db; do
110                 db=$(basename "$base" .db)
111
112                 if [ -f /etc/mail/$db ]; then
113                         echo -n "$db "
114                         /usr/sbin/postmap hash:/etc/mail/$db < /etc/mail/$db
115                 fi
116         done
117         echo "...DONE"
118
119         echo -n "Rebuilding aliases database"
120         /usr/bin/newaliases
121         echo "...DONE"
122         ;;
123   status)
124         status master
125         exit $?
126         ;;
127   *)
128         msg_usage "$0 {start|stop|restart|reload|force-reload|rebuilddb|status}"
129         exit 3
130 esac
131
132 exit $RETVAL
This page took 0.060486 seconds and 4 git commands to generate.