[9199] | 1 | #!/bin/bash |
---|
| 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 | # processname: sendmail |
---|
| 10 | # config: /etc/mail/sendmail.cf |
---|
| 11 | # pidfile: /var/run/sendmail.pid |
---|
| 12 | |
---|
| 13 | # Source function library. |
---|
| 14 | . /etc/rc.d/init.d/functions |
---|
| 15 | |
---|
| 16 | # Source networking configuration. |
---|
| 17 | [ -f /etc/sysconfig/network ] && . /etc/sysconfig/network |
---|
| 18 | |
---|
| 19 | # Source sendmail configureation. |
---|
| 20 | if [ -f /etc/sysconfig/sendmail ] ; then |
---|
| 21 | . /etc/sysconfig/sendmail |
---|
| 22 | else |
---|
| 23 | DAEMON=no |
---|
| 24 | QUEUE=1h |
---|
| 25 | fi |
---|
| 26 | [ -z "$SMQUEUE" ] && SMQUEUE="$QUEUE" |
---|
| 27 | [ -z "$SMQUEUE" ] && SMQUEUE=1h |
---|
| 28 | |
---|
| 29 | # Check that networking is up. |
---|
| 30 | [ "${NETWORKING}" = "no" ] && exit 0 |
---|
| 31 | |
---|
| 32 | [ -f /usr/sbin/sendmail ] || exit 0 |
---|
| 33 | |
---|
| 34 | RETVAL=0 |
---|
| 35 | prog="sendmail" |
---|
| 36 | |
---|
| 37 | start() { |
---|
| 38 | # Start daemons. |
---|
| 39 | |
---|
| 40 | echo -n $"Starting $prog: " |
---|
| 41 | if test -x /usr/bin/make -a -f /etc/mail/Makefile ; then |
---|
| 42 | make all -C /etc/mail -s |
---|
| 43 | else |
---|
| 44 | for i in virtusertable access domaintable mailertable ; do |
---|
| 45 | if [ -f /etc/mail/$i ] ; then |
---|
| 46 | makemap hash /etc/mail/$i < /etc/mail/$i |
---|
| 47 | fi |
---|
| 48 | done |
---|
| 49 | fi |
---|
| 50 | /usr/bin/newaliases > /dev/null 2>&1 |
---|
| 51 | daemon /usr/sbin/sendmail $([ "x$DAEMON" = xyes ] && echo -bd) \ |
---|
| 52 | $([ -n "$QUEUE" ] && echo -q$QUEUE) $SENDMAIL_OPTARG |
---|
| 53 | RETVAL=$? |
---|
| 54 | echo |
---|
| 55 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sendmail |
---|
| 56 | |
---|
| 57 | if ! test -f /var/run/sm-client.pid ; then |
---|
| 58 | echo -n $"Starting sm-client: " |
---|
| 59 | touch /var/run/sm-client.pid |
---|
| 60 | chown smmsp:smmsp /var/run/sm-client.pid |
---|
| 61 | daemon --check sm-client /usr/sbin/sendmail -L sm-msp-queue -Ac \ |
---|
| 62 | -q $SMQUEUE $SENDMAIL_OPTARG |
---|
| 63 | RETVAL=$? |
---|
| 64 | echo |
---|
| 65 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sm-client |
---|
| 66 | fi |
---|
| 67 | |
---|
| 68 | return $RETVAL |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | reload() { |
---|
| 72 | # Stop daemons. |
---|
| 73 | echo -n $"reloading $prog: " |
---|
| 74 | /usr/bin/newaliases > /dev/null 2>&1 |
---|
| 75 | if [ -x /usr/bin/make -a -f /etc/mail/Makefile ]; then |
---|
| 76 | make all -C /etc/mail -s |
---|
| 77 | else |
---|
| 78 | for i in virtusertable access domaintable mailertable ; do |
---|
| 79 | if [ -f /etc/mail/$i ] ; then |
---|
| 80 | makemap hash /etc/mail/$i < /etc/mail/$i |
---|
| 81 | fi |
---|
| 82 | done |
---|
| 83 | fi |
---|
| 84 | daemon /usr/sbin/sendmail $([ "x$DAEMON" = xyes ] && echo -bd) \ |
---|
| 85 | $([ -n "$QUEUE" ] && echo -q$QUEUE) |
---|
| 86 | RETVAL=$? |
---|
| 87 | killproc sendmail -HUP |
---|
| 88 | RETVAL=$? |
---|
| 89 | echo |
---|
| 90 | if [ $RETVAL -eq 0 -a -f /var/run/sm-client.pid ]; then |
---|
| 91 | echo -n $"reloading sm-client: " |
---|
| 92 | killproc sm-client -HUP |
---|
| 93 | RETVAL=$? |
---|
| 94 | echo |
---|
| 95 | fi |
---|
| 96 | return $RETVAL |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | stop() { |
---|
| 100 | # Stop daemons. |
---|
| 101 | echo -n $"Shutting down $prog: " |
---|
| 102 | killproc sendmail |
---|
| 103 | RETVAL=$? |
---|
| 104 | echo |
---|
| 105 | [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sendmail |
---|
| 106 | if test -f /var/run/sm-client.pid ; then |
---|
| 107 | echo -n $"Shutting down sm-client: " |
---|
| 108 | killproc sm-client |
---|
| 109 | RETVAL=$? |
---|
| 110 | echo |
---|
| 111 | [ $RETVAL -eq 0 ] && rm -f /var/run/sm-client.pid |
---|
| 112 | [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sm-client |
---|
| 113 | fi |
---|
| 114 | return $RETVAL |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | # See how we were called. |
---|
| 118 | case "$1" in |
---|
| 119 | start) |
---|
| 120 | start |
---|
| 121 | ;; |
---|
| 122 | stop) |
---|
| 123 | stop |
---|
| 124 | ;; |
---|
| 125 | reload) |
---|
| 126 | reload |
---|
| 127 | RETVAL=$? |
---|
| 128 | ;; |
---|
| 129 | restart) |
---|
| 130 | stop |
---|
| 131 | start |
---|
| 132 | RETVAL=$? |
---|
| 133 | ;; |
---|
| 134 | condrestart) |
---|
| 135 | if [ -f /var/lock/subsys/sendmail ]; then |
---|
| 136 | stop |
---|
| 137 | start |
---|
| 138 | RETVAL=$? |
---|
| 139 | fi |
---|
| 140 | ;; |
---|
| 141 | status) |
---|
| 142 | status sendmail |
---|
| 143 | RETVAL=$? |
---|
| 144 | ;; |
---|
| 145 | *) |
---|
| 146 | echo $"Usage: $0 {start|stop|restart|condrestart|status}" |
---|
| 147 | exit 1 |
---|
| 148 | esac |
---|
| 149 | |
---|
| 150 | exit $RETVAL |
---|