1*fcf3ce44SJohn Forte#!/bin/sh 2*fcf3ce44SJohn Forte# CDDL HEADER START 3*fcf3ce44SJohn Forte# 4*fcf3ce44SJohn Forte# The contents of this file are subject to the terms of the 5*fcf3ce44SJohn Forte# Common Development and Distribution License (the "License"). 6*fcf3ce44SJohn Forte# You may not use this file except in compliance with the License. 7*fcf3ce44SJohn Forte# 8*fcf3ce44SJohn Forte# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*fcf3ce44SJohn Forte# or http://www.opensolaris.org/os/licensing. 10*fcf3ce44SJohn Forte# See the License for the specific language governing permissions 11*fcf3ce44SJohn Forte# and limitations under the License. 12*fcf3ce44SJohn Forte# 13*fcf3ce44SJohn Forte# When distributing Covered Code, include this CDDL HEADER in each 14*fcf3ce44SJohn Forte# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*fcf3ce44SJohn Forte# If applicable, add the following below this CDDL HEADER, with the 16*fcf3ce44SJohn Forte# fields enclosed by brackets "[]" replaced with your own identifying 17*fcf3ce44SJohn Forte# information: Portions Copyright [yyyy] [name of copyright owner] 18*fcf3ce44SJohn Forte# 19*fcf3ce44SJohn Forte# CDDL HEADER END 20*fcf3ce44SJohn Forte# 21*fcf3ce44SJohn Forte# 22*fcf3ce44SJohn Forte# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23*fcf3ce44SJohn Forte# Use is subject to license terms. 24*fcf3ce44SJohn Forte# 25*fcf3ce44SJohn ForteCMD=/usr/sbin/iiboot 26*fcf3ce44SJohn ForteIIADM=/usr/sbin/iiadm 27*fcf3ce44SJohn ForteSVCS=/usr/bin/svcs 28*fcf3ce44SJohn ForteDSCFG_DEPEND_NOCHK="/tmp/.dscfgadm_pid" 29*fcf3ce44SJohn ForteOS_MINOR=`/usr/bin/uname -r | /usr/bin/cut -d '.' -f2` 30*fcf3ce44SJohn Forte 31*fcf3ce44SJohn Forte. /lib/svc/share/smf_include.sh 32*fcf3ce44SJohn Forte 33*fcf3ce44SJohn Forte# Make sure prior SMF dependents are not 'online' 34*fcf3ce44SJohn Forte# $1 = name of SMF service to validate dependents 35*fcf3ce44SJohn Forte# 36*fcf3ce44SJohn Fortedo_smf_depends () 37*fcf3ce44SJohn Forte{ 38*fcf3ce44SJohn Forte times=0 39*fcf3ce44SJohn Forte count=1 40*fcf3ce44SJohn Forte 41*fcf3ce44SJohn Forte if [ $OS_MINOR -ge 11 ] 42*fcf3ce44SJohn Forte then 43*fcf3ce44SJohn Forte return 0 44*fcf3ce44SJohn Forte elif [ -f $DSCFG_DEPEND_NOCHK ] 45*fcf3ce44SJohn Forte then 46*fcf3ce44SJohn Forte for pid in `pgrep dscfgadm` 47*fcf3ce44SJohn Forte do 48*fcf3ce44SJohn Forte if [ `grep -c $pid $DSCFG_DEPEND_NOCHK` -gt 0 ] 49*fcf3ce44SJohn Forte then 50*fcf3ce44SJohn Forte return 0 51*fcf3ce44SJohn Forte fi 52*fcf3ce44SJohn Forte done 53*fcf3ce44SJohn Forte elif [ `ps -ef | grep preremove | grep -c SUNWiiu` -gt 0 ] 54*fcf3ce44SJohn Forte then 55*fcf3ce44SJohn Forte return 0 56*fcf3ce44SJohn Forte 57*fcf3ce44SJohn Forte fi 58*fcf3ce44SJohn Forte 59*fcf3ce44SJohn Forte while [ $count -ne 0 ] 60*fcf3ce44SJohn Forte do 61*fcf3ce44SJohn Forte count=`$SVCS -o STATE -D $1 2>>/dev/null | grep "^online" | wc -l` 62*fcf3ce44SJohn Forte if [ $count -ne 0 ] 63*fcf3ce44SJohn Forte then 64*fcf3ce44SJohn Forte # Output banner after waiting first 5 seconds 65*fcf3ce44SJohn Forte # 66*fcf3ce44SJohn Forte if [ $times -eq 1 ] 67*fcf3ce44SJohn Forte then 68*fcf3ce44SJohn Forte echo "Waiting for $1 dependents to be 'offline'" 69*fcf3ce44SJohn Forte $SVCS -D $1 2>>/dev/null | grep "^online" 70*fcf3ce44SJohn Forte fi 71*fcf3ce44SJohn Forte 72*fcf3ce44SJohn Forte # Has it been longer then 5 minutes? (60 * 5 secs.) 73*fcf3ce44SJohn Forte # 74*fcf3ce44SJohn Forte if [ $times -eq 60 ] 75*fcf3ce44SJohn Forte then 76*fcf3ce44SJohn Forte echo "Error: Failed waiting for $1 dependents to be 'offline'" 77*fcf3ce44SJohn Forte $SVCS -D $1 2>>/dev/null | grep "^online" 78*fcf3ce44SJohn Forte exit $SMF_EXIT_ERR_FATAL 79*fcf3ce44SJohn Forte fi 80*fcf3ce44SJohn Forte 81*fcf3ce44SJohn Forte # Now sleep, giving other services time to stop 82*fcf3ce44SJohn Forte # 83*fcf3ce44SJohn Forte sleep 5 84*fcf3ce44SJohn Forte times=`expr $times + 1` 85*fcf3ce44SJohn Forte fi 86*fcf3ce44SJohn Forte done 87*fcf3ce44SJohn Forte return 0 88*fcf3ce44SJohn Forte} 89*fcf3ce44SJohn Forte 90*fcf3ce44SJohn Forte 91*fcf3ce44SJohn ForteCLINFO=/usr/sbin/clinfo 92*fcf3ce44SJohn Forte 93*fcf3ce44SJohn Forterc=0 94*fcf3ce44SJohn Forte 95*fcf3ce44SJohn Fortecase $1 in 96*fcf3ce44SJohn Forte'start') 97*fcf3ce44SJohn Forte 98*fcf3ce44SJohn Forte COPT= 99*fcf3ce44SJohn Forte 100*fcf3ce44SJohn Forte if [ -x ${CMD} ] 101*fcf3ce44SJohn Forte then 102*fcf3ce44SJohn Forte if ${CLINFO} 103*fcf3ce44SJohn Forte then 104*fcf3ce44SJohn Forte # in cluster - look for local volumes only 105*fcf3ce44SJohn Forte COPT="-C -" 106*fcf3ce44SJohn Forte fi 107*fcf3ce44SJohn Forte 108*fcf3ce44SJohn Forte ${CMD} $COPT -r > /dev/null 2>&1 109*fcf3ce44SJohn Forte rc=$? 110*fcf3ce44SJohn Forte fi 111*fcf3ce44SJohn Forte ;; 112*fcf3ce44SJohn Forte'stop') 113*fcf3ce44SJohn Forte if [ ! -r /dev/ii ] 114*fcf3ce44SJohn Forte then 115*fcf3ce44SJohn Forte exit $SMF_EXIT_OK 116*fcf3ce44SJohn Forte fi 117*fcf3ce44SJohn Forte 118*fcf3ce44SJohn Forte do_smf_depends "system/nws_ii" 119*fcf3ce44SJohn Forte 120*fcf3ce44SJohn Forte COPT= 121*fcf3ce44SJohn Forte 122*fcf3ce44SJohn Forte if [ -x ${CMD} ] 123*fcf3ce44SJohn Forte then 124*fcf3ce44SJohn Forte if ${CLINFO} 125*fcf3ce44SJohn Forte then 126*fcf3ce44SJohn Forte # in cluster - look for local volumes only 127*fcf3ce44SJohn Forte COPT="-C -" 128*fcf3ce44SJohn Forte fi 129*fcf3ce44SJohn Forte 130*fcf3ce44SJohn Forte ${CMD} $COPT -s > /dev/null 2>&1 131*fcf3ce44SJohn Forte rc=$? 132*fcf3ce44SJohn Forte fi 133*fcf3ce44SJohn Forte ;; 134*fcf3ce44SJohn Forte*) 135*fcf3ce44SJohn Forte echo "usage: /etc/init.d/ii {start|stop} " 136*fcf3ce44SJohn Forte exit 1 137*fcf3ce44SJohn Forte ;; 138*fcf3ce44SJohn Forteesac 139*fcf3ce44SJohn Forteif [ $rc -ne 0 ] 140*fcf3ce44SJohn Fortethen 141*fcf3ce44SJohn Forte exit $SMF_MON_OFFLINE 142*fcf3ce44SJohn Forteelse 143*fcf3ce44SJohn Forte exit $SMF_EXIT_OK 144*fcf3ce44SJohn Fortefi 145