Blame | Last modification | View Log | RSS feed
#!/bin/bash## sendmail This shell script takes care of starting and stopping# sendmail.## chkconfig: 2345 80 30# description: Sendmail is a Mail Transport Agent, which is the program \# that moves mail from one machine to another.# processname: sendmail# config: /etc/mail/sendmail.cf# pidfile: /var/run/sendmail.pid### BEGIN INIT INFO# Provides: sendmail MTA smtpdaemon# Required-Start: $local_fs $network# Required-Stop: $local_fs $network# Default-Start: 2 3 4 5# Default-Stop: 0 1 6# Short-Description: start and stop sendmail# Description: sendmail is a Mail Transport Agent (MTA)### END INIT INFO# Source function library.. /etc/rc.d/init.d/functions# Source networking configuration.[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network# Source sendmail configureation.if [ -f /etc/sysconfig/sendmail ]; then. /etc/sysconfig/sendmailelseDAEMON=noQUEUE=1hfi[ -z "$SMQUEUE" ] && SMQUEUE="$QUEUE"[ -z "$SMQUEUE" ] && SMQUEUE=1h# Check that we're a privileged user[ `id -u` = 0 ] || exit 4# Check that networking is up.[ "${NETWORKING}" = "no" ] && exit 1[ -x /usr/sbin/sendmail ] || exit 5prog="sendmail"updateconf() {/etc/mail/make > /dev/null 2>&1if [ $? -eq 15 ]; thenecho -n $"Package sendmail-cf is required to update configuration."warningechofi/etc/mail/make aliases > /dev/null 2>&1}start() {# Start daemons.ret=0updateconfecho -n $"Starting $prog: "daemon /usr/sbin/sendmail $([ "x$DAEMON" = xyes ] && echo -bd) \$([ -n "$QUEUE" ] && echo -q$QUEUE) $SENDMAIL_OPTARGRETVAL=$?echo[ $RETVAL -eq 0 ] && touch /var/lock/subsys/sendmaillet ret+=$RETVALif [ ! -f /var/run/sm-client.pid ]; thenecho -n $"Starting sm-client: "touch /var/run/sm-client.pidchown smmsp:smmsp /var/run/sm-client.pidif [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then/sbin/restorecon /var/run/sm-client.pidfidaemon --check sm-client /usr/sbin/sendmail -L sm-msp-queue -Ac \-q$SMQUEUE $SENDMAIL_OPTARGRETVAL=$?echo[ $RETVAL -eq 0 ] && touch /var/lock/subsys/sm-clientlet ret+=$RETVALfi[ $ret -eq 0 ] && return 0 || return 1}reload() {updateconfecho -n $"Reloading $prog: "killproc sendmail -HUPRETVAL=$?echoif [ $RETVAL -eq 0 -a -f /var/run/sm-client.pid ]; thenecho -n $"reloading sm-client: "killproc sm-client -HUPRETVAL=$?echofireturn $RETVAL}stop() {# Stop daemons.if [ -f /var/run/sm-client.pid ]; thenecho -n $"Shutting down sm-client: "killproc sm-clientRETVAL=$?echo[ $RETVAL -eq 0 ] && rm -f /var/run/sm-client.pid[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sm-clientfiecho -n $"Shutting down $prog: "killproc sendmailRETVAL=$?echo[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sendmailreturn $RETVAL}status -p /var/run/sendmail.pid >/dev/null || status -p /var/run/sm-client.pid >/dev/nullrunning=$?# See how we were called.case "$1" instart)[ $running -eq 0 ] && exit 0startRETVAL=$?;;stop)[ $running -eq 0 ] || exit 0stopRETVAL=$?;;reload)[ $running -eq 0 ] || exit 7reloadRETVAL=$?;;restart|force-reload)stopstartRETVAL=$?;;condrestart|try-restart)[ $running -eq 0 ] || exit 0stopstartRETVAL=$?;;status)echo -n sendmail; status -p /var/run/sendmail.pid -l sendmailRETVAL=$?echo -n sm-client; status -p /var/run/sm-client.pid -l sm-client[ $RETVAL -eq 0 ] && RETVAL=$?;;*)echo $"Usage: $0 {start|stop|restart|condrestart|status}"RETVAL=2esacexit $RETVAL