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 Forte# SNDR start script 26*fcf3ce44SJohn Forte# 27*fcf3ce44SJohn Forte# Description: This is the SNDR start script. It must be located 28*fcf3ce44SJohn Forte# in /etc/init.d with links to the appropriate rc2.d and 29*fcf3ce44SJohn Forte# rc0.d files. 30*fcf3ce44SJohn Forte# It can also be used to start or stop a specified cluster 31*fcf3ce44SJohn Forte# resource group when invoked from the data service cluster 32*fcf3ce44SJohn Forte# failover script. 33*fcf3ce44SJohn Forte# 34*fcf3ce44SJohn Forte# 35*fcf3ce44SJohn Forte# 36*fcf3ce44SJohn FortePATH=/etc:/bin 37*fcf3ce44SJohn ForteRDCBOOT="/usr/sbin/sndrboot" 38*fcf3ce44SJohn ForteUSAGE="Usage: $0 {start|stop} [cluster_resource]" 39*fcf3ce44SJohn ForteSVCS=/usr/bin/svcs 40*fcf3ce44SJohn ForteDSCFG_DEPEND_NOCHK="/tmp/.dscfgadm_pid" 41*fcf3ce44SJohn ForteOS_MINOR=`/usr/bin/uname -r | /usr/bin/cut -d '.' -f2` 42*fcf3ce44SJohn Forte 43*fcf3ce44SJohn Forte. /lib/svc/share/smf_include.sh 44*fcf3ce44SJohn Forte 45*fcf3ce44SJohn Forte# Make sure prior SMF dependents are not 'online' 46*fcf3ce44SJohn Forte# $1 = name of SMF service to validate dependents 47*fcf3ce44SJohn Forte# 48*fcf3ce44SJohn Fortedo_smf_depends () 49*fcf3ce44SJohn Forte{ 50*fcf3ce44SJohn Forte times=0 51*fcf3ce44SJohn Forte count=1 52*fcf3ce44SJohn Forte 53*fcf3ce44SJohn Forte if [ $OS_MINOR -ge 11 ] 54*fcf3ce44SJohn Forte then 55*fcf3ce44SJohn Forte return 0 56*fcf3ce44SJohn Forte elif [ -f $DSCFG_DEPEND_NOCHK ] 57*fcf3ce44SJohn Forte then 58*fcf3ce44SJohn Forte for pid in `pgrep dscfgadm` 59*fcf3ce44SJohn Forte do 60*fcf3ce44SJohn Forte if [ `grep -c $pid $DSCFG_DEPEND_NOCHK` -gt 0 ] 61*fcf3ce44SJohn Forte then 62*fcf3ce44SJohn Forte return 0 63*fcf3ce44SJohn Forte fi 64*fcf3ce44SJohn Forte done 65*fcf3ce44SJohn Forte elif [ `ps -ef | grep preremove | grep -c SUNWrdcu` -gt 0 ] 66*fcf3ce44SJohn Forte then 67*fcf3ce44SJohn Forte return 0 68*fcf3ce44SJohn Forte 69*fcf3ce44SJohn Forte fi 70*fcf3ce44SJohn Forte 71*fcf3ce44SJohn Forte while [ $count -ne 0 ] 72*fcf3ce44SJohn Forte do 73*fcf3ce44SJohn Forte count=`$SVCS -o STATE -D $1 2>>/dev/null | grep "^online" | wc -l` 74*fcf3ce44SJohn Forte if [ $count -ne 0 ] 75*fcf3ce44SJohn Forte then 76*fcf3ce44SJohn Forte # Output banner after waiting first 5 seconds 77*fcf3ce44SJohn Forte # 78*fcf3ce44SJohn Forte if [ $times -eq 1 ] 79*fcf3ce44SJohn Forte then 80*fcf3ce44SJohn Forte echo "Waiting for $1 dependents to be 'offline'" 81*fcf3ce44SJohn Forte $SVCS -D $1 2>>/dev/null | grep "^online" 82*fcf3ce44SJohn Forte fi 83*fcf3ce44SJohn Forte 84*fcf3ce44SJohn Forte # Has it been longer then 5 minutes? (60 * 5 secs.) 85*fcf3ce44SJohn Forte # 86*fcf3ce44SJohn Forte if [ $times -eq 60 ] 87*fcf3ce44SJohn Forte then 88*fcf3ce44SJohn Forte echo "Error: Failed waiting for $1 dependents to be 'offline'" 89*fcf3ce44SJohn Forte $SVCS -D $1 2>>/dev/null | grep "^online" 90*fcf3ce44SJohn Forte exit $SMF_EXIT_ERR_FATAL 91*fcf3ce44SJohn Forte fi 92*fcf3ce44SJohn Forte 93*fcf3ce44SJohn Forte # Now sleep, giving other services time to stop 94*fcf3ce44SJohn Forte # 95*fcf3ce44SJohn Forte sleep 5 96*fcf3ce44SJohn Forte times=`expr $times + 1` 97*fcf3ce44SJohn Forte fi 98*fcf3ce44SJohn Forte done 99*fcf3ce44SJohn Forte return 0 100*fcf3ce44SJohn Forte} 101*fcf3ce44SJohn Forte 102*fcf3ce44SJohn ForteCLINFO=/usr/sbin/clinfo 103*fcf3ce44SJohn Forte 104*fcf3ce44SJohn Fortekillproc() { # kill the named process(es) 105*fcf3ce44SJohn Forte pid=`/usr/bin/ps -e | 106*fcf3ce44SJohn Forte /usr/bin/grep -w $1 | 107*fcf3ce44SJohn Forte /usr/bin/sed -e 's/^ *//' -e 's/ .*//'` 108*fcf3ce44SJohn Forte [ "$pid" != "" ] && kill $pid 109*fcf3ce44SJohn Forte} 110*fcf3ce44SJohn Forte 111*fcf3ce44SJohn Forte 112*fcf3ce44SJohn Fortecase "$1" in 113*fcf3ce44SJohn Forte'start') 114*fcf3ce44SJohn Forte COPT= 115*fcf3ce44SJohn Forte 116*fcf3ce44SJohn Forte if [ -x ${RDCBOOT} ] 117*fcf3ce44SJohn Forte then 118*fcf3ce44SJohn Forte if ${CLINFO} 119*fcf3ce44SJohn Forte then 120*fcf3ce44SJohn Forte if [ "$2" != "" ] 121*fcf3ce44SJohn Forte then 122*fcf3ce44SJohn Forte ${RDCBOOT} -r -C $2 123*fcf3ce44SJohn Forte else 124*fcf3ce44SJohn Forte # SNDR 3.2 SetIDs fixup 125*fcf3ce44SJohn Forte ${RDCBOOT} -C post-patch-setids -r -s 126*fcf3ce44SJohn Forte 127*fcf3ce44SJohn Forte COPT="-C -" 128*fcf3ce44SJohn Forte ${RDCBOOT} ${COPT} -r 129*fcf3ce44SJohn Forte fi 130*fcf3ce44SJohn Forte else 131*fcf3ce44SJohn Forte # non-clustered start 132*fcf3ce44SJohn Forte ${RDCBOOT} -r 133*fcf3ce44SJohn Forte fi 134*fcf3ce44SJohn Forte fi 135*fcf3ce44SJohn Forte ;; 136*fcf3ce44SJohn Forte 137*fcf3ce44SJohn Forte'stop') 138*fcf3ce44SJohn Forte COPT= 139*fcf3ce44SJohn Forte 140*fcf3ce44SJohn Forte if [ ! -r /dev/rdc ] 141*fcf3ce44SJohn Forte then 142*fcf3ce44SJohn Forte RDCBOOT=/usr/bin/true 143*fcf3ce44SJohn Forte fi 144*fcf3ce44SJohn Forte 145*fcf3ce44SJohn Forte do_smf_depends "system/nws_rdc" 146*fcf3ce44SJohn Forte 147*fcf3ce44SJohn Forte if [ -x ${RDCBOOT} ] 148*fcf3ce44SJohn Forte then 149*fcf3ce44SJohn Forte if ${CLINFO} 150*fcf3ce44SJohn Forte then 151*fcf3ce44SJohn Forte if [ "$2" != "" ] 152*fcf3ce44SJohn Forte then 153*fcf3ce44SJohn Forte ${RDCBOOT} -s -C $2 154*fcf3ce44SJohn Forte else 155*fcf3ce44SJohn Forte COPT="-C -" 156*fcf3ce44SJohn Forte ${RDCBOOT} ${COPT} -s 157*fcf3ce44SJohn Forte 158*fcf3ce44SJohn Forte echo "killing SNDR daemons" 159*fcf3ce44SJohn Forte killproc sndrd 160*fcf3ce44SJohn Forte killproc sndrsync 161*fcf3ce44SJohn Forte fi 162*fcf3ce44SJohn Forte else 163*fcf3ce44SJohn Forte # non-clustered stop 164*fcf3ce44SJohn Forte 165*fcf3ce44SJohn Forte ${RDCBOOT} -s 166*fcf3ce44SJohn Forte 167*fcf3ce44SJohn Forte echo "killing SNDR daemons" 168*fcf3ce44SJohn Forte killproc sndrd 169*fcf3ce44SJohn Forte killproc sndrsync 170*fcf3ce44SJohn Forte fi 171*fcf3ce44SJohn Forte else 172*fcf3ce44SJohn Forte # no sndr boot command, kill daemon anyway 173*fcf3ce44SJohn Forte 174*fcf3ce44SJohn Forte echo "killing SNDR daemons" 175*fcf3ce44SJohn Forte killproc sndrd 176*fcf3ce44SJohn Forte killproc sndrsync 177*fcf3ce44SJohn Forte fi 178*fcf3ce44SJohn Forte 179*fcf3ce44SJohn Forte ;; 180*fcf3ce44SJohn Forte 181*fcf3ce44SJohn Forte*) 182*fcf3ce44SJohn Forte echo $USAGE 183*fcf3ce44SJohn Forte exit 1 184*fcf3ce44SJohn Forte ;; 185*fcf3ce44SJohn Forteesac 186*fcf3ce44SJohn Forteexit $SMF_EXIT_OK 187