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