]> git.pld-linux.org Git - packages/sendmail.git/blame - sendmail.init
- added URL
[packages/sendmail.git] / sendmail.init
CommitLineData
56e84bcc 1#! /bin/sh
c81b1a7a 2#
1da91524 3# sendmail This shell script takes care of starting and stopping
4# sendmail.
c81b1a7a 5#
56e84bcc 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
c81b1a7a 10
56e84bcc 11
12# Source function library
c81b1a7a 13. /etc/rc.d/init.d/functions
14
56e84bcc 15# Get network config
c81b1a7a 16. /etc/sysconfig/network
17
56e84bcc 18# Get service config
cbfcadea 19if [ -f /etc/sysconfig/sendmail ]; then
20 . /etc/sysconfig/sendmail
21else
22 DAEMON=yes
1da91524 23 QUEUE=1h
cbfcadea 24 ENABLE_IPV6=yes
25fi
d18ae119
PG
26[ -z "$SMQUEUE" ] && SMQUEUE="$QUEUE"
27[ -z "$SMQUEUE" ] && SMQUEUE=1h
c81b1a7a 28
56e84bcc 29# Check that networking is up.
1da91524 30if is_yes "${NETWORKING}"; then
200e4f5c 31 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
1da91524 32 msg_network_down Sendmail
33 exit 1
34 fi
35else
36 exit 0
d402e605 37fi
c81b1a7a 38
131de62f 39RETVAL=0
c81b1a7a 40# See how we were called.
41case "$1" in
42 start)
56e84bcc 43 # Check if the service is already running?
44 if [ ! -f /var/lock/subsys/sendmail ]; then
7a537bd8 45 show "Prepare sendmail db"
56e84bcc 46 busy
cbfcadea 47 /usr/bin/newaliases >/dev/null 2>&1
56e84bcc 48 for i in virtusertable access domaintable mailertable; do
131de62f 49 if [ -f /etc/mail/$i ]; then
d730b467 50 makemap -v hash /etc/mail/$i < /etc/mail/$i >/dev/null 2>&1
131de62f 51 [ $RETVAL -eq 0 ] && RETVAL=$?
56e84bcc 52 fi
34b97b70 53 done
131de62f 54 [ $RETVAL -eq 0 ] && ok || fail
7a537bd8 55 msg_starting sendmail
cbfcadea 56 daemon /usr/sbin/sendmail $([ "$DAEMON" = "yes" ] && echo -bd) \
57 $([ -n "$QUEUE" ] && echo -q$QUEUE) \
34b97b70 58 $([ "$ENABLE_IPV6" = "yes" ] &&
cbfcadea 59 echo -ODaemonPortOptions=Family=inet6 )
60 RETVAL=$?
61 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sendmail
56e84bcc 62 else
e905adcf 63 msg_already_running sendmail
c99e5551 64 fi
d18ae119
PG
65 if [ ! -f /var/lock/subsys/sm-client ]; then
66 msg_starting sm-client
d18ae119
PG
67 daemon /usr/sbin/sendmail -L sm-msp-queue -Ac -q$SMQUEUE
68 RETVAL=$?
69 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sm-client
70 else
71 msg_already_running sm-client
72 fi
c81b1a7a 73 ;;
74 stop)
1da91524 75 if [ -f /var/lock/subsys/sendmail ]; then
76 # Stop daemons.
77 msg_stopping sendmail
c7a045e3
ER
78 killproc --pidfile sendmail.pid sendmail
79 RETVAL=$?
80 [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sendmail
1da91524 81 else
82 msg_not_running sendmail
1da91524 83 fi
d18ae119
PG
84 if [ -f /var/lock/subsys/sm-client ]; then
85 msg_stopping sm-client
c7a045e3 86 killproc --pidfile /var/spool/clientmqueue/sm-client.pid sendmail
d18ae119 87 RETVAL=$?
d18ae119
PG
88 [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sm-client
89 else
90 msg_not_running sm-client
91 fi
c81b1a7a 92 ;;
24371448 93 restart)
c81b1a7a 94 $0 stop
95 $0 start
1da91524 96 exit $?
cbfcadea 97 ;;
24371448 98 reload|force-reload)
d18ae119
PG
99 # TODO: make it better for sm-client
100 if [ -f /var/lock/subsys/sendmail ]; then
101 msg_reloading sendmail
102 busy
103 killproc sendmail -HUP
104 RETVAL=$?
105 else
106 msg_not_running sendmail
107 fi
108 ;;
c81b1a7a 109 status)
110 status sendmail
131de62f 111 exit $?
c81b1a7a 112 ;;
113 *)
d18ae119 114 msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
131de62f 115 exit 3
c81b1a7a 116esac
117
cbfcadea 118exit $RETVAL
This page took 0.041974 seconds and 4 git commands to generate.