da978630d1f0b07bd370e402117d4d9b17bac427John Beck#!/sbin/sh
da978630d1f0b07bd370e402117d4d9b17bac427John Beck#
da978630d1f0b07bd370e402117d4d9b17bac427John Beck# CDDL HEADER START
da978630d1f0b07bd370e402117d4d9b17bac427John Beck#
da978630d1f0b07bd370e402117d4d9b17bac427John Beck# The contents of this file are subject to the terms of the
da978630d1f0b07bd370e402117d4d9b17bac427John Beck# Common Development and Distribution License (the "License").
da978630d1f0b07bd370e402117d4d9b17bac427John Beck# You may not use this file except in compliance with the License.
da978630d1f0b07bd370e402117d4d9b17bac427John Beck#
da978630d1f0b07bd370e402117d4d9b17bac427John Beck# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da978630d1f0b07bd370e402117d4d9b17bac427John Beck# or http://www.opensolaris.org/os/licensing.
da978630d1f0b07bd370e402117d4d9b17bac427John Beck# See the License for the specific language governing permissions
da978630d1f0b07bd370e402117d4d9b17bac427John Beck# and limitations under the License.
da978630d1f0b07bd370e402117d4d9b17bac427John Beck#
da978630d1f0b07bd370e402117d4d9b17bac427John Beck# When distributing Covered Code, include this CDDL HEADER in each
da978630d1f0b07bd370e402117d4d9b17bac427John Beck# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da978630d1f0b07bd370e402117d4d9b17bac427John Beck# If applicable, add the following below this CDDL HEADER, with the
da978630d1f0b07bd370e402117d4d9b17bac427John Beck# fields enclosed by brackets "[]" replaced with your own identifying
da978630d1f0b07bd370e402117d4d9b17bac427John Beck# information: Portions Copyright [yyyy] [name of copyright owner]
da978630d1f0b07bd370e402117d4d9b17bac427John Beck#
da978630d1f0b07bd370e402117d4d9b17bac427John Beck# CDDL HEADER END
da978630d1f0b07bd370e402117d4d9b17bac427John Beck#
da978630d1f0b07bd370e402117d4d9b17bac427John Beck# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
da978630d1f0b07bd370e402117d4d9b17bac427John Beck# Use is subject to license terms.
da978630d1f0b07bd370e402117d4d9b17bac427John Beck
da978630d1f0b07bd370e402117d4d9b17bac427John Beck. /lib/svc/share/smf_include.sh
da978630d1f0b07bd370e402117d4d9b17bac427John Beck. /lib/svc/share/sendmail_include.sh
da978630d1f0b07bd370e402117d4d9b17bac427John Beck
da978630d1f0b07bd370e402117d4d9b17bac427John BeckCLIENT_PID_FILE="/var/spool/clientmqueue/sm-client.pid"
da978630d1f0b07bd370e402117d4d9b17bac427John BeckSUBMIT_CF="/etc/mail/submit.cf"
da978630d1f0b07bd370e402117d4d9b17bac427John Beck
da978630d1f0b07bd370e402117d4d9b17bac427John Beckcase "$1" in
da978630d1f0b07bd370e402117d4d9b17bac427John Beck'refresh')
da978630d1f0b07bd370e402117d4d9b17bac427John Beck [ -f $CLIENT_PID_FILE ] && kill -1 `head -1 $CLIENT_PID_FILE`
da978630d1f0b07bd370e402117d4d9b17bac427John Beck ;;
da978630d1f0b07bd370e402117d4d9b17bac427John Beck
da978630d1f0b07bd370e402117d4d9b17bac427John Beck'start')
da978630d1f0b07bd370e402117d4d9b17bac427John Beck exist_or_exit $SENDMAIL
da978630d1f0b07bd370e402117d4d9b17bac427John Beck [ -f $DEFAULT_FILE ] && . $DEFAULT_FILE
da978630d1f0b07bd370e402117d4d9b17bac427John Beck #
da978630d1f0b07bd370e402117d4d9b17bac427John Beck # * CLIENTQUEUEINTERVAL should be set to some legal value;
da978630d1f0b07bd370e402117d4d9b17bac427John Beck # sanity checks are done below.
da978630d1f0b07bd370e402117d4d9b17bac427John Beck # * CLIENTOPTIONS are catch-alls; set with care.
da978630d1f0b07bd370e402117d4d9b17bac427John Beck #
da978630d1f0b07bd370e402117d4d9b17bac427John Beck check_queue_interval_syntax $CLIENTQUEUEINTERVAL
da978630d1f0b07bd370e402117d4d9b17bac427John Beck CLIENTQUEUEINTERVAL=$answer
da978630d1f0b07bd370e402117d4d9b17bac427John Beck
da978630d1f0b07bd370e402117d4d9b17bac427John Beck submit_path=`svcprop -p config/path_to_submit_mc $SMF_FMRI 2>/dev/null`
da978630d1f0b07bd370e402117d4d9b17bac427John Beck if [ $? -eq 0 -a -n "$submit_path" ]; then
39b0b3b7a730af51562e3efcb6ee9a2c52f62fb3John Beck turn_m4_crank "$SUBMIT_CF" "$submit_path"
da978630d1f0b07bd370e402117d4d9b17bac427John Beck fi
39b0b3b7a730af51562e3efcb6ee9a2c52f62fb3John Beck exist_or_exit "$SUBMIT_CF"
da978630d1f0b07bd370e402117d4d9b17bac427John Beck
da978630d1f0b07bd370e402117d4d9b17bac427John Beck $SENDMAIL -Ac -q$CLIENTQUEUEINTERVAL $CLIENTOPTIONS &
da978630d1f0b07bd370e402117d4d9b17bac427John Beck ;;
da978630d1f0b07bd370e402117d4d9b17bac427John Beck
da978630d1f0b07bd370e402117d4d9b17bac427John Beck'stop')
da978630d1f0b07bd370e402117d4d9b17bac427John Beck if [ -f $CLIENT_PID_FILE ]; then
da978630d1f0b07bd370e402117d4d9b17bac427John Beck check_and_kill $CLIENT_PID_FILE
da978630d1f0b07bd370e402117d4d9b17bac427John Beck rm -f $CLIENT_PID_FILE
da978630d1f0b07bd370e402117d4d9b17bac427John Beck fi
da978630d1f0b07bd370e402117d4d9b17bac427John Beck # Need to kill the entire service contract to kill all sendmail related
da978630d1f0b07bd370e402117d4d9b17bac427John Beck # processes
da978630d1f0b07bd370e402117d4d9b17bac427John Beck smf_kill_contract $2 TERM 1 30
da978630d1f0b07bd370e402117d4d9b17bac427John Beck ret=$?
da978630d1f0b07bd370e402117d4d9b17bac427John Beck [ $ret -eq 1 ] && exit 1
da978630d1f0b07bd370e402117d4d9b17bac427John Beck
da978630d1f0b07bd370e402117d4d9b17bac427John Beck # Sendmail can take its time responding to SIGTERM, as it waits for
da978630d1f0b07bd370e402117d4d9b17bac427John Beck # things like child processes and SMTP connections to clean up. If
da978630d1f0b07bd370e402117d4d9b17bac427John Beck # the contract did not empty after TERM, move on to KILL.
da978630d1f0b07bd370e402117d4d9b17bac427John Beck if [ $ret -eq 2 ] ; then
da978630d1f0b07bd370e402117d4d9b17bac427John Beck smf_kill_contract $2 KILL 1
da978630d1f0b07bd370e402117d4d9b17bac427John Beck fi
da978630d1f0b07bd370e402117d4d9b17bac427John Beck ;;
da978630d1f0b07bd370e402117d4d9b17bac427John Beck
da978630d1f0b07bd370e402117d4d9b17bac427John Beck*)
da978630d1f0b07bd370e402117d4d9b17bac427John Beck echo "Usage: $0 { start | stop | refresh }"
da978630d1f0b07bd370e402117d4d9b17bac427John Beck exit 1
da978630d1f0b07bd370e402117d4d9b17bac427John Beck ;;
da978630d1f0b07bd370e402117d4d9b17bac427John Beckesac
da978630d1f0b07bd370e402117d4d9b17bac427John Beckexit 0