#!/bin/sh # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # SNDR start script # # Description: This is the SNDR start script. It must be located # in /etc/init.d with links to the appropriate rc2.d and # rc0.d files. # It can also be used to start or stop a specified cluster # resource group when invoked from the data service cluster # failover script. # # # setvar PATH = "/etc:/bin" setvar RDCBOOT = ""/usr/sbin/sndrboot"" setvar USAGE = ""Usage: $0 {start|stop} [cluster_resource]"" setvar SVCS = '/usr/bin/svcs' setvar DSCFG_DEPEND_NOCHK = ""/tmp/.dscfgadm_pid"" setvar OS_MINOR = $(/usr/bin/uname -r | /usr/bin/cut -d '.' -f2) source /lib/svc/share/smf_include.sh # Make sure prior SMF dependents are not 'online' # $1 = name of SMF service to validate dependents # proc do_smf_depends { setvar times = '0' setvar count = '1' if test $OS_MINOR -ge 11 { return 0 } elif test -f $DSCFG_DEPEND_NOCHK { for pid in [$(pgrep dscfgadm)] { if test $(grep -c $pid $DSCFG_DEPEND_NOCHK) -gt 0 { return 0 } } } elif test $(ps -ef | grep preremove | grep -c SUNWrdcu) -gt 0 { return 0 } while [ $count -ne 0 ] { setvar count = $($SVCS -o STATE -D $1 2>>/dev/null | grep "^online" | wc -l) if test $count -ne 0 { # Output banner after waiting first 5 seconds # if test $times -eq 1 { echo "Waiting for $1 dependents to be 'offline'" $SVCS -D $1 2>>/dev/null | grep "^online" } # Has it been longer then 5 minutes? (60 * 5 secs.) # if test $times -eq 60 { echo "Error: Failed waiting for $1 dependents to be 'offline'" $SVCS -D $1 2>>/dev/null | grep "^online" exit $SMF_EXIT_ERR_FATAL } # Now sleep, giving other services time to stop # sleep 5 setvar times = $(expr $times + 1) } } return 0 } setvar CLINFO = '/usr/sbin/clinfo' proc killproc { # kill the named process(es) setvar pid = $(/usr/bin/ps -e | /usr/bin/grep -w $1 | /usr/bin/sed -e 's/^ *//' -e 's/ .*//) test $pid != "" && kill $pid } match $1 { with 'start' setvar COPT = '' if test -x ${RDCBOOT} { if ${CLINFO} { if test $2 != "" { ${RDCBOOT} -r -C $2 } else { # SNDR 3.2 SetIDs fixup ${RDCBOOT} -C post-patch-setids -r -s setvar COPT = ""-C -"" ${RDCBOOT} ${COPT} -r } } else { # non-clustered start ${RDCBOOT} -r } } with 'stop' setvar COPT = '' if test ! -r /dev/rdc { setvar RDCBOOT = '/usr/bin/true' } do_smf_depends "system/nws_rdc" if test -x ${RDCBOOT} { if ${CLINFO} { if test $2 != "" { ${RDCBOOT} -s -C $2 } else { setvar COPT = ""-C -"" ${RDCBOOT} ${COPT} -s echo "killing SNDR daemons" killproc sndrd killproc sndrsync } } else { # non-clustered stop ${RDCBOOT} -s echo "killing SNDR daemons" killproc sndrd killproc sndrsync } } else { # no sndr boot command, kill daemon anyway echo "killing SNDR daemons" killproc sndrd killproc sndrsync } with * echo $USAGE exit 1 } exit $SMF_EXIT_OK