]> git.pld-linux.org Git - packages/sendmail.git/blob - sendmail.init
- up to 8.15.2
[packages/sendmail.git] / sendmail.init
1 #! /bin/sh
2 #
3 # sendmail      This shell script takes care of starting and stopping
4 #               sendmail.
5 #
6 # chkconfig:    2345 80 30
7 # description:  Sendmail is a Mail Transport Agent, which is the program \
8 #               that moves mail from one machine to another.
9 # pidfile:      /var/run/sendmail.pid
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 if [ -f /etc/sysconfig/sendmail ]; then
20         . /etc/sysconfig/sendmail
21 else
22         DAEMON=yes
23         QUEUE=1h
24         ENABLE_IPV6=yes
25 fi
26 [ -z "$SMQUEUE" ] && SMQUEUE="$QUEUE"
27 [ -z "$SMQUEUE" ] && SMQUEUE=1h
28
29 # Check that networking is up.
30 if is_yes "${NETWORKING}"; then
31         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
32                 msg_network_down Sendmail
33                 exit 1
34         fi
35 else
36         exit 0
37 fi
38
39 start() {
40         # Check if the service is already running?
41         if [ ! -f /var/lock/subsys/sendmail ]; then
42                 show "Prepare sendmail db"
43                 busy
44                 /usr/bin/newaliases >/dev/null 2>&1
45                 for i in virtusertable access domaintable mailertable; do
46                         if [ -f /etc/mail/$i ]; then
47                                 makemap -v hash /etc/mail/$i < /etc/mail/$i >/dev/null 2>&1
48                                 [ $RETVAL -eq 0 ] && RETVAL=$?
49                         fi
50                 done
51                 [ $RETVAL -eq 0 ] && ok || fail
52                 msg_starting sendmail
53                 daemon /usr/sbin/sendmail $([ "$DAEMON" = "yes" ] && echo -bd) \
54                                         $([ -n "$QUEUE" ] && echo -q$QUEUE) \
55                                         $([ "$ENABLE_IPV6" = "yes" ] &&
56                                                 echo -ODaemonPortOptions=Family=inet6 )
57                 RETVAL=$?
58                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sendmail
59         else
60                 msg_already_running sendmail
61         fi
62         if [ ! -f /var/lock/subsys/sm-client ]; then
63                 msg_starting sm-client
64                 daemon /usr/sbin/sendmail -L sm-msp-queue -Ac -q$SMQUEUE
65                 RETVAL=$?
66                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sm-client
67         else
68                 msg_already_running sm-client
69         fi
70 }
71
72 stop() {
73         if [ -f /var/lock/subsys/sendmail ]; then
74                 # Stop daemons.
75                 msg_stopping sendmail
76                 killproc --pidfile sendmail.pid sendmail
77                 RETVAL=$?
78                 [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sendmail
79         else
80                 msg_not_running sendmail
81         fi
82         if [ -f /var/lock/subsys/sm-client ]; then
83                 msg_stopping sm-client
84                 killproc --pidfile /var/spool/clientmqueue/sm-client.pid sendmail
85                 RETVAL=$?
86                 [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sm-client
87         else
88                 msg_not_running sm-client
89         fi
90 }
91
92 RETVAL=0
93 # See how we were called.
94 case "$1" in
95   start)
96         start
97         ;;
98   stop)
99         stop
100         ;;
101   restart)
102         stop
103         start
104         ;;
105   reload|force-reload)
106         # TODO: make it better for sm-client
107         if [ -f /var/lock/subsys/sendmail ]; then
108                 msg_reloading sendmail
109                 busy
110                 killproc sendmail -HUP
111                 RETVAL=$?
112         else
113                 msg_not_running sendmail
114         fi
115         ;;
116   status)
117         status sendmail
118         exit $?
119         ;;
120   *)
121         msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
122         exit 3
123 esac
124
125 exit $RETVAL
This page took 0.044569 seconds and 3 git commands to generate.