3 # sendmail This shell script takes care of starting and stopping
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
12 # Source function library
13 . /etc/rc.d/init.d/functions
16 . /etc/sysconfig/network
19 if [ -f /etc/sysconfig/sendmail ]; then
20 . /etc/sysconfig/sendmail
26 [ -z "$SMQUEUE" ] && SMQUEUE="$QUEUE"
27 [ -z "$SMQUEUE" ] && SMQUEUE=1h
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
40 # See how we were called.
43 # Check if the service is already running?
44 if [ ! -f /var/lock/subsys/sendmail ]; then
45 show "Prepare sendmail db"
47 /usr/bin/newaliases >/dev/null 2>&1
48 for i in virtusertable access domaintable mailertable; do
49 if [ -f /etc/mail/$i ]; then
50 makemap -v hash /etc/mail/$i < /etc/mail/$i >/dev/null 2>&1
51 [ $RETVAL -eq 0 ] && RETVAL=$?
54 [ $RETVAL -eq 0 ] && ok || fail
56 daemon /usr/sbin/sendmail $([ "$DAEMON" = "yes" ] && echo -bd) \
57 $([ -n "$QUEUE" ] && echo -q$QUEUE) \
58 $([ "$ENABLE_IPV6" = "yes" ] &&
59 echo -ODaemonPortOptions=Family=inet6 )
61 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sendmail
63 msg_already_running sendmail
65 if [ ! -f /var/lock/subsys/sm-client ]; then
66 msg_starting sm-client
67 touch /var/run/sm-client.pid
68 chown smmsp:smmsp /var/run/sm-client.pid
69 daemon /usr/sbin/sendmail -L sm-msp-queue -Ac -q$SMQUEUE
71 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sm-client
73 msg_already_running sm-client
77 if [ -f /var/lock/subsys/sendmail ]; then
81 rm -f /var/lock/subsys/sendmail
83 msg_not_running sendmail
85 if [ -f /var/lock/subsys/sm-client ]; then
86 msg_stopping sm-client
89 [ $RETVAL -eq 0 ] && rm -f /var/run/sm-client.pid
90 [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sm-client
92 msg_not_running sm-client
101 # TODO: make it better for sm-client
102 if [ -f /var/lock/subsys/sendmail ]; then
103 msg_reloading sendmail
105 killproc sendmail -HUP
108 msg_not_running sendmail
116 msg_usage "$0 {start|stop|restart|reload|force-reload|status}"