]> git.pld-linux.org Git - packages/postfix.git/blob - postfix.init
- nice service fixed
[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=$(nice -n ${SERVICE_RUN_NICE_LEVEL:-${DEFAULT_SERVICE_RUN_NICE_LEVEL:-0}} /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                 if [ $RETVAL -eq 0 ]; then
79                         ok
80                 else
81                         fail
82                         echo >&2 "$msg"
83                         RETVAL=7
84                 fi
85         else
86                 msg_not_running "Postfix"
87                 RETVAL=7
88         fi
89 }
90
91 RETVAL=0
92 # See how we were called.
93 case "$1" in
94   start)
95         networking_check
96         start
97         ;;
98   stop)
99         stop
100         ;;
101   restart)
102         networking_check
103         stop
104         start
105         ;;
106   reload|force-reload)
107         networking_check
108         reload
109         ;;
110   rebuilddb)
111         standard_db="access canonical relocated transport virtual"
112         extra_db=$(ls -1 /etc/mail/*.db 2> /dev/null | egrep -v '/(access|canonical|relocated|transport|virtual|aliases)\.db$')
113
114         echo -n "Rebuilding databases: "
115         for base in $standard_db $extra_db; do
116                 db=$(basename "$base" .db)
117
118                 if [ -f /etc/mail/$db ]; then
119                         echo -n "$db "
120                         /usr/sbin/postmap hash:/etc/mail/$db < /etc/mail/$db
121                 fi
122         done
123         echo "...DONE"
124
125         echo -n "Rebuilding aliases database"
126         /usr/bin/newaliases
127         echo "...DONE"
128         ;;
129   status)
130         status master
131         exit $?
132         ;;
133   *)
134         msg_usage "$0 {start|stop|restart|reload|force-reload|rebuilddb|status}"
135         exit 3
136 esac
137
138 exit $RETVAL
This page took 0.041168 seconds and 4 git commands to generate.