fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#!/bin/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# SNDR start script
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Description: This is the SNDR start script. It must be located
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# in /etc/init.d with links to the appropriate rc2.d and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# rc0.d files.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# It can also be used to start or stop a specified cluster
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# resource group when invoked from the data service cluster
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# failover script.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortePATH=/etc:/bin
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteRDCBOOT="/usr/sbin/sndrboot"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteUSAGE="Usage: $0 {start|stop} [cluster_resource]"
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 SUNWrdcu` -gt 0 ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fi
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 ForteCLINFO=/usr/sbin/clinfo
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortekillproc() { # kill the named process(es)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pid=`/usr/bin/ps -e |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /usr/bin/grep -w $1 |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /usr/bin/sed -e 's/^ *//' -e 's/ .*//'`
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte [ "$pid" != "" ] && kill $pid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecase "$1" in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte'start')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte COPT=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ -x ${RDCBOOT} ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ${CLINFO}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ "$2" != "" ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ${RDCBOOT} -r -C $2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # SNDR 3.2 SetIDs fixup
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ${RDCBOOT} -C post-patch-setids -r -s
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte COPT="-C -"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ${RDCBOOT} ${COPT} -r
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fi
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # non-clustered start
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ${RDCBOOT} -r
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fi
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fi
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ;;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte'stop')
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte COPT=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ ! -r /dev/rdc ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDCBOOT=/usr/bin/true
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fi
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do_smf_depends "system/nws_rdc"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ -x ${RDCBOOT} ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ${CLINFO}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ "$2" != "" ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ${RDCBOOT} -s -C $2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte COPT="-C -"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ${RDCBOOT} ${COPT} -s
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "killing SNDR daemons"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte killproc sndrd
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte killproc sndrsync
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fi
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # non-clustered stop
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ${RDCBOOT} -s
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "killing SNDR daemons"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte killproc sndrd
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte killproc sndrsync
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fi
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # no sndr boot command, kill daemon anyway
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "killing SNDR daemons"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte killproc sndrd
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte killproc sndrsync
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fi
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ;;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte*)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo $USAGE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ;;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteesac
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteexit $SMF_EXIT_OK