fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#!/sbin/sh
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte[ ! -d /usr/sbin -o ! -d /usr/bin ] && exit
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Constants
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteSVBOOT=/usr/sbin/svboot
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteSVCS=/usr/bin/svcs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteDSCFG_DEPEND_NOCHK="/tmp/.dscfgadm_pid"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteOS_MINOR=`/usr/bin/uname -r | /usr/bin/cut -d '.' -f2`
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte. /lib/svc/share/smf_include.sh
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Make sure prior SMF dependents are not 'online'
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# $1 = name of SMF service to validate dependents
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedo_smf_depends ()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte times=0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count=1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $OS_MINOR -ge 11 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte elif [ -f $DSCFG_DEPEND_NOCHK ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for pid in `pgrep dscfgadm`
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ `grep -c $pid $DSCFG_DEPEND_NOCHK` -gt 0 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fi
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte done
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte elif [ `ps -ef | grep preremove | grep -c SUNWspsvu` -gt 0 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fi
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while [ $count -ne 0 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count=`$SVCS -o STATE -D $1 2>>/dev/null | grep "^online" | wc -l`
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $count -ne 0 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # Output banner after waiting first 5 seconds
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte #
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $times -eq 1 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "Waiting for $1 dependents to be 'offline'"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte $SVCS -D $1 2>>/dev/null | grep "^online"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fi
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # Has it been longer then 5 minutes? (60 * 5 secs.)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte #
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $times -eq 60 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "Error: Failed waiting for $1 dependents to be 'offline'"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte $SVCS -D $1 2>>/dev/null | grep "^online"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit $SMF_EXIT_ERR_FATAL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fi
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # Now sleep, giving other services time to stop
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte #
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sleep 5
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte times=`expr $times + 1`
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fi
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte done
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# main program
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteif [ ! -x $SVBOOT ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortethen
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "$0: cannot find $SVBOOT"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit $SMF_EXIT_MON_OFFLINE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefi
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecase "$1" in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte'start')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte $SVBOOT -r
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ;;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte'stop')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do_smf_depends "system/nws_sv"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte $SVBOOT -s
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ;;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte*)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "Usage: $0 { start | stop }"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit $SMF_EXIT_MON_OFFLINE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ;;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteesac
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteexit $SMF_EXIT_OK