]>
Commit | Line | Data |
---|---|---|
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 | 19 | if [ -f /etc/sysconfig/sendmail ]; then |
20 | . /etc/sysconfig/sendmail | |
21 | else | |
22 | DAEMON=yes | |
1da91524 | 23 | QUEUE=1h |
cbfcadea | 24 | ENABLE_IPV6=yes |
25 | fi | |
c81b1a7a | 26 | |
56e84bcc | 27 | # Check that networking is up. |
1da91524 | 28 | if is_yes "${NETWORKING}"; then |
29 | if [ ! -f /var/lock/subsys/network ]; then | |
30 | msg_network_down Sendmail | |
31 | exit 1 | |
32 | fi | |
33 | else | |
34 | exit 0 | |
d402e605 | 35 | fi |
c81b1a7a | 36 | |
1da91524 | 37 | |
c81b1a7a | 38 | # See how we were called. |
39 | case "$1" in | |
40 | start) | |
56e84bcc | 41 | # Check if the service is already running? |
42 | if [ ! -f /var/lock/subsys/sendmail ]; then | |
7a537bd8 | 43 | show "Prepare sendmail db" |
56e84bcc | 44 | busy |
cbfcadea | 45 | /usr/bin/newaliases >/dev/null 2>&1 |
56e84bcc | 46 | for i in virtusertable access domaintable mailertable; do |
47 | if [ -f /etc/mail/$i ] ; then | |
d730b467 | 48 | makemap -v hash /etc/mail/$i < /etc/mail/$i >/dev/null 2>&1 |
56e84bcc | 49 | fi |
50 | done | |
1da91524 | 51 | ok |
7a537bd8 | 52 | msg_starting sendmail |
cbfcadea | 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 | |
56e84bcc | 59 | else |
e905adcf | 60 | msg_already_running sendmail |
7a537bd8 | 61 | exit 1 |
c99e5551 | 62 | fi |
c81b1a7a | 63 | ;; |
64 | stop) | |
1da91524 | 65 | if [ -f /var/lock/subsys/sendmail ]; then |
66 | # Stop daemons. | |
67 | msg_stopping sendmail | |
68 | killproc sendmail | |
69 | RETVAL=$? | |
70 | rm -f /var/lock/subsys/sendmail | |
71 | else | |
72 | msg_not_running sendmail | |
73 | exit 1 | |
74 | fi | |
c81b1a7a | 75 | ;; |
56e84bcc | 76 | restart|reload) |
c81b1a7a | 77 | $0 stop |
78 | $0 start | |
79 | ;; | |
1da91524 | 80 | force-reload) |
81 | $0 stop && $0 start | |
82 | exit $? | |
cbfcadea | 83 | ;; |
c81b1a7a | 84 | status) |
85 | status sendmail | |
cbfcadea | 86 | RETVAL=$? |
c81b1a7a | 87 | ;; |
88 | *) | |
1da91524 | 89 | msg_usage "$0 {start|stop|restart|reload|force-reload|status}" |
c81b1a7a | 90 | exit 1 |
91 | esac | |
92 | ||
cbfcadea | 93 | exit $RETVAL |