smtp-sendmail revision da978630d1f0b07bd370e402117d4d9b17bac427
4812N/A#!/sbin/sh
4812N/A#
4812N/A# CDDL HEADER START
4812N/A#
4812N/A# The contents of this file are subject to the terms of the
4812N/A# Common Development and Distribution License (the "License").
4812N/A# You may not use this file except in compliance with the License.
4812N/A#
4812N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
4812N/A# or http://www.opensolaris.org/os/licensing.
4812N/A# See the License for the specific language governing permissions
4812N/A# and limitations under the License.
4812N/A#
4812N/A# When distributing Covered Code, include this CDDL HEADER in each
4812N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
4812N/A# If applicable, add the following below this CDDL HEADER, with the
4812N/A# fields enclosed by brackets "[]" replaced with your own identifying
4812N/A# information: Portions Copyright [yyyy] [name of copyright owner]
4812N/A#
4812N/A# CDDL HEADER END
4812N/A#
4812N/A# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
4812N/A# Use is subject to license terms.
4812N/A
4812N/A. /lib/svc/share/smf_include.sh
4812N/A. /lib/svc/share/sendmail_include.sh
4812N/A
4812N/AERRMSG1='WARNING: /var/mail is NFS-mounted without setting actimeo=0,'
4812N/AERRMSG2='this can cause mailbox locking and access problems.'
4812N/ASERVER_PID_FILE="/var/run/sendmail.pid"
4812N/AALIASES_FILE="/etc/mail/aliases"
4812N/ASENDMAIL_CF="/etc/mail/sendmail.cf"
4845N/A
4812N/Acase "$1" in
4812N/A'refresh')
4812N/A [ -f $SERVER_PID_FILE ] && kill -1 `head -1 $SERVER_PID_FILE`
4812N/A ;;
4812N/A
4812N/A'start')
4812N/A exist_or_exit $SENDMAIL
4812N/A if [ ! -d /var/spool/mqueue ]; then
4812N/A /usr/bin/mkdir -m 0750 /var/spool/mqueue
4812N/A /usr/bin/chown root:bin /var/spool/mqueue
4812N/A fi
4812N/A if [ ! -f $ALIASES_FILE.db ] && [ ! -f $ALIASES_FILE.dir ] \
4812N/A && [ ! -f $ALIASES_FILE.pag ]; then
4812N/A /usr/sbin/newaliases
4812N/A fi
4812N/A MODE="-bd"
4812N/A [ -f $DEFAULT_FILE ] && . $DEFAULT_FILE
4812N/A #
4812N/A # * MODE should be "-bd" or null (MODE= or MODE="") or
4812N/A # left alone. Anything else and you're on your own.
4812N/A # * QUEUEOPTION should be "p" or null (as above).
4812N/A # * QUEUEINTERVAL should be set to some legal value;
4812N/A # sanity checks are done below.
4812N/A # * OPTIONS are catch-alls; set with care.
4812N/A #
4812N/A if [ -n "$QUEUEOPTION" -a "$QUEUEOPTION" != "p" ]; then
4812N/A QUEUEOPTION=""
4812N/A fi
4812N/A if [ -z "$QUEUEOPTION" -o -n "$QUEUEINTERVAL" ]; then
4812N/A check_queue_interval_syntax $QUEUEINTERVAL
4812N/A QUEUEINTERVAL=$answer
4812N/A fi
4812N/A
4812N/A local=`/usr/bin/svcprop -p config/local_only $SMF_FMRI 2>/dev/null`
4812N/A if [ $? -eq 0 -a "$local" = "true" ]; then
4812N/A MODE="-bl"
4812N/A fi
4812N/A sendmail_path=`svcprop -p config/path_to_sendmail_mc $SMF_FMRI \
4812N/A 2>/dev/null`
4812N/A if [ $? -eq 0 -a -n "$sendmail_path" ]; then
4812N/A turn_m4_crank $SENDMAIL_CF $sendmail_path
4812N/A fi
4812N/A exist_or_exit $SENDMAIL_CF
4812N/A
4812N/A $SENDMAIL $MODE -q$QUEUEOPTION$QUEUEINTERVAL $OPTIONS &
4812N/A
4812N/A #
4812N/A # ETRN_HOSTS should be of the form
4812N/A # "s1:c1.1,c1.2 s2:c2.1 s3:c3.1,c3.2,c3.3"
4812N/A # i.e., white-space separated groups of server:client where
4812N/A # client can be one or more comma-separated names; N.B. that
4812N/A # the :client part is optional; see etrn(1M) for details.
4812N/A # server is the name of the server to prod; a mail queue run
4812N/A # is requested for each client name. This is comparable to
4812N/A # running "/usr/lib/sendmail -qRclient" on the host server.
4812N/A #
4812N/A # See RFC 1985 for more information.
4812N/A #
4812N/A for i in $ETRN_HOSTS; do
4812N/A SERVER=`echo $i | /usr/bin/sed -e 's/:.*$//'`
4812N/A CLIENTS=`echo $i | /usr/bin/sed -n -e 's/,/ /g' \
4812N/A -e '/:/s/^.*://p'`
4812N/A /usr/sbin/etrn -b $SERVER $CLIENTS >/dev/null 2>&1 &
4812N/A done
4812N/A
4812N/A if /usr/bin/nawk 'BEGIN{s = 1}
4812N/A $2 == "/var/mail" && $3 == "nfs" && $4 !~ /actimeo=0/ &&
4812N/A $4 !~ /noac/{s = 0} END{exit s}' /etc/mnttab; then
4812N/A
4812N/A /usr/bin/logger -p mail.crit "$ERRMSG1"
4812N/A /usr/bin/logger -p mail.crit "$ERRMSG2"
4812N/A fi
4812N/A ;;
4812N/A
4812N/A'stop')
4812N/A [ -f $SERVER_PID_FILE ] && check_and_kill $SERVER_PID_FILE
4812N/A # Need to kill the entire service contract to kill all sendmail related
4812N/A # processes
4812N/A smf_kill_contract $2 TERM 1 30
4812N/A ret=$?
4812N/A [ $ret -eq 1 ] && exit 1
4812N/A
4812N/A # Since sendmail spawns user processes out of .forward files, it is
4812N/A # possible that some of these are not responding to TERM. If the
4812N/A # contract did not empty after TERM, move on to KILL.
4812N/A if [ $ret -eq 2 ] ; then
4812N/A smf_kill_contract $2 KILL 1
4812N/A fi
4812N/A ;;
4812N/A
4812N/A*)
4812N/A echo "Usage: $0 { start | stop | refresh }"
4812N/A exit 1
4812N/A ;;
esac
exit 0