]> git.pld-linux.org Git - packages/sendmail.git/blame - sendmail.init
- x32 rebuild
[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
8db27308 39start() {
56e84bcc 40 # Check if the service is already running?
41 if [ ! -f /var/lock/subsys/sendmail ]; then
7a537bd8 42 show "Prepare sendmail db"
56e84bcc 43 busy
cbfcadea 44 /usr/bin/newaliases >/dev/null 2>&1
56e84bcc 45 for i in virtusertable access domaintable mailertable; do
131de62f 46 if [ -f /etc/mail/$i ]; then
d730b467 47 makemap -v hash /etc/mail/$i < /etc/mail/$i >/dev/null 2>&1
131de62f 48 [ $RETVAL -eq 0 ] && RETVAL=$?
56e84bcc 49 fi
34b97b70 50 done
131de62f 51 [ $RETVAL -eq 0 ] && ok || fail
7a537bd8 52 msg_starting sendmail
cbfcadea 53 daemon /usr/sbin/sendmail $([ "$DAEMON" = "yes" ] && echo -bd) \
54 $([ -n "$QUEUE" ] && echo -q$QUEUE) \
34b97b70 55 $([ "$ENABLE_IPV6" = "yes" ] &&
cbfcadea 56 echo -ODaemonPortOptions=Family=inet6 )
57 RETVAL=$?
58 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sendmail
56e84bcc 59 else
e905adcf 60 msg_already_running sendmail
c99e5551 61 fi
d18ae119
PG
62 if [ ! -f /var/lock/subsys/sm-client ]; then
63 msg_starting sm-client
d18ae119
PG
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
8db27308
ER
70}
71
72stop() {
1da91524 73 if [ -f /var/lock/subsys/sendmail ]; then
74 # Stop daemons.
75 msg_stopping sendmail
c7a045e3
ER
76 killproc --pidfile sendmail.pid sendmail
77 RETVAL=$?
78 [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sendmail
1da91524 79 else
80 msg_not_running sendmail
1da91524 81 fi
d18ae119
PG
82 if [ -f /var/lock/subsys/sm-client ]; then
83 msg_stopping sm-client
c7a045e3 84 killproc --pidfile /var/spool/clientmqueue/sm-client.pid sendmail
d18ae119 85 RETVAL=$?
d18ae119
PG
86 [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sm-client
87 else
88 msg_not_running sm-client
89 fi
8db27308
ER
90}
91
92RETVAL=0
93# See how we were called.
94case "$1" in
95 start)
96 start
97 ;;
98 stop)
99 stop
c81b1a7a 100 ;;
24371448 101 restart)
8db27308
ER
102 stop
103 start
cbfcadea 104 ;;
24371448 105 reload|force-reload)
d18ae119
PG
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 ;;
c81b1a7a 116 status)
117 status sendmail
131de62f 118 exit $?
c81b1a7a 119 ;;
120 *)
d18ae119 121 msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
131de62f 122 exit 3
c81b1a7a 123esac
124
cbfcadea 125exit $RETVAL
This page took 0.073793 seconds and 4 git commands to generate.