1*7836SJohn.Forte@Sun.COM#!/usr/bin/ksh 2*7836SJohn.Forte@Sun.COM# CDDL HEADER START 3*7836SJohn.Forte@Sun.COM# 4*7836SJohn.Forte@Sun.COM# The contents of this file are subject to the terms of the 5*7836SJohn.Forte@Sun.COM# Common Development and Distribution License (the "License"). 6*7836SJohn.Forte@Sun.COM# You may not use this file except in compliance with the License. 7*7836SJohn.Forte@Sun.COM# 8*7836SJohn.Forte@Sun.COM# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*7836SJohn.Forte@Sun.COM# or http://www.opensolaris.org/os/licensing. 10*7836SJohn.Forte@Sun.COM# See the License for the specific language governing permissions 11*7836SJohn.Forte@Sun.COM# and limitations under the License. 12*7836SJohn.Forte@Sun.COM# 13*7836SJohn.Forte@Sun.COM# When distributing Covered Code, include this CDDL HEADER in each 14*7836SJohn.Forte@Sun.COM# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*7836SJohn.Forte@Sun.COM# If applicable, add the following below this CDDL HEADER, with the 16*7836SJohn.Forte@Sun.COM# fields enclosed by brackets "[]" replaced with your own identifying 17*7836SJohn.Forte@Sun.COM# information: Portions Copyright [yyyy] [name of copyright owner] 18*7836SJohn.Forte@Sun.COM# 19*7836SJohn.Forte@Sun.COM# CDDL HEADER END 20*7836SJohn.Forte@Sun.COM# 21*7836SJohn.Forte@Sun.COM# 22*7836SJohn.Forte@Sun.COM# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23*7836SJohn.Forte@Sun.COM# Use is subject to license terms. 24*7836SJohn.Forte@Sun.COM# 25*7836SJohn.Forte@Sun.COM# NWS DataServices within SunCluster reconfiguration script. 26*7836SJohn.Forte@Sun.COM# 27*7836SJohn.Forte@Sun.COM# Description: 28*7836SJohn.Forte@Sun.COM# 29*7836SJohn.Forte@Sun.COM# This script is called from /usr/cluster/lib/sc/run_reserve at 30*7836SJohn.Forte@Sun.COM# appropriate times to start and stop the NWS DataServices as SunCluster 31*7836SJohn.Forte@Sun.COM# disk device groups are brought online or taken offline. 32*7836SJohn.Forte@Sun.COM# 33*7836SJohn.Forte@Sun.COM# SNDR configuration requires that a resource group to be configured. 34*7836SJohn.Forte@Sun.COM# 1. The resource group name should be same as device group name with -stor-rg 35*7836SJohn.Forte@Sun.COM# added. e.g. if device group name is abc-dg then resource group name 36*7836SJohn.Forte@Sun.COM# would be abc-dg-stor-rg. 37*7836SJohn.Forte@Sun.COM# 2. It should have 2 resources in it, unless one of the resource types is the 38*7836SJohn.Forte@Sun.COM# SUNW.GeoCtlAVS. One of type SUNW.LogicalHostname and either SUNW.HAStorage 39*7836SJohn.Forte@Sun.COM# or SUNW.HAStoragePlus types. Resource type versioning is ignored. 40*7836SJohn.Forte@Sun.COM# HAStorage type resource, should have ServicePaths property set to 41*7836SJohn.Forte@Sun.COM# device group name. HAStoragePlus type resource, should have either the 42*7836SJohn.Forte@Sun.COM# FilesystemMountPoints pointing to a files system associated with the 43*7836SJohn.Forte@Sun.COM# device group name, or GlobalDevicePaths property set to device group name. 44*7836SJohn.Forte@Sun.COM# LogicalHostname type resource should have a failoverIP address in it and 45*7836SJohn.Forte@Sun.COM# it will be used by SNDR to communicate with the secondary side. 46*7836SJohn.Forte@Sun.COM# 47*7836SJohn.Forte@Sun.COM# As SNDR requires that the LogicalHost (failover) IP address which is a 48*7836SJohn.Forte@Sun.COM# part of resource group for SNDR, to be hosted on the same node where the 49*7836SJohn.Forte@Sun.COM# device group is, it tries to move the resource group also alongwith the 50*7836SJohn.Forte@Sun.COM# device group, in become_primary case of run_reserve script. While 51*7836SJohn.Forte@Sun.COM# in primary_to_secondary case, it will try to kill the switchover function 52*7836SJohn.Forte@Sun.COM# if it is still running in background, after stopping NWS data services. 53*7836SJohn.Forte@Sun.COM# 54*7836SJohn.Forte@Sun.COM# Usage: 55*7836SJohn.Forte@Sun.COM# 56*7836SJohn.Forte@Sun.COM# /usr/cluster/sbin/dscfg_reconfigure { start | stop } diskgroup 57*7836SJohn.Forte@Sun.COM# 58*7836SJohn.Forte@Sun.COM# Configuration: 59*7836SJohn.Forte@Sun.COM# 60*7836SJohn.Forte@Sun.COM# Scripts to be run should have been symlinked into $NWS_START_DIR and 61*7836SJohn.Forte@Sun.COM# $NWS_STOP_DIR. Note that the scripts are processed in lexical order, 62*7836SJohn.Forte@Sun.COM# and that unlike /etc/rc?.d/ there is no leading S or K character. 63*7836SJohn.Forte@Sun.COM# 64*7836SJohn.Forte@Sun.COM# Exit status: 65*7836SJohn.Forte@Sun.COM# 66*7836SJohn.Forte@Sun.COM# 0 - success 67*7836SJohn.Forte@Sun.COM# 1 - error 68*7836SJohn.Forte@Sun.COM# 69*7836SJohn.Forte@Sun.COM 70*7836SJohn.Forte@Sun.COM# 71*7836SJohn.Forte@Sun.COM# Global variables 72*7836SJohn.Forte@Sun.COM# 73*7836SJohn.Forte@Sun.COM 74*7836SJohn.Forte@Sun.COM# this program 75*7836SJohn.Forte@Sun.COMtypeset -r ARGV0=$(basename $0) 76*7836SJohn.Forte@Sun.COM 77*7836SJohn.Forte@Sun.COM# directory full of start scripts 78*7836SJohn.Forte@Sun.COMtypeset -r NWS_START_DIR=/usr/cluster/lib/dscfg/start 79*7836SJohn.Forte@Sun.COM 80*7836SJohn.Forte@Sun.COM# directory full of stop scripts 81*7836SJohn.Forte@Sun.COMtypeset -r NWS_STOP_DIR=/usr/cluster/lib/dscfg/stop 82*7836SJohn.Forte@Sun.COM 83*7836SJohn.Forte@Sun.COM# the syslog facility to use. 84*7836SJohn.Forte@Sun.COM# - conceptually this should be based on the output of 85*7836SJohn.Forte@Sun.COM# "scha_cluster_get -O SYSLOG_FACILITY", but that won't work early 86*7836SJohn.Forte@Sun.COM# during boot. 87*7836SJohn.Forte@Sun.COMtypeset -r SYSLOG_FACILITY=daemon 88*7836SJohn.Forte@Sun.COM 89*7836SJohn.Forte@Sun.COMPATH=$PATH:/usr/cluster/bin:/etc 90*7836SJohn.Forte@Sun.COM 91*7836SJohn.Forte@Sun.COM# Variables for retrying scswitch of Resource group for SNDR 92*7836SJohn.Forte@Sun.COMretry_num=12 93*7836SJohn.Forte@Sun.COMretry_interval=10 94*7836SJohn.Forte@Sun.COMrgname= 95*7836SJohn.Forte@Sun.COMrgstat= 96*7836SJohn.Forte@Sun.COMskip_resource=0 97*7836SJohn.Forte@Sun.COMcount_LogicalHostname=0 98*7836SJohn.Forte@Sun.COMcount_HAStoragePlus=0 99*7836SJohn.Forte@Sun.COM 100*7836SJohn.Forte@Sun.COM# Since the switchover of the resource group is called in background, 101*7836SJohn.Forte@Sun.COM# the stop action of the reconfig script will kill the background switchover 102*7836SJohn.Forte@Sun.COM# if it is running. Since we are stopping the NWS services on the node, there 103*7836SJohn.Forte@Sun.COM# is no need to switch the resource group, so it is killed. 104*7836SJohn.Forte@Sun.COM# The pid of the process is kept in file /var/run/scnws/$dg.pid. 105*7836SJohn.Forte@Sun.COM# Input: dg - device group 106*7836SJohn.Forte@Sun.COM# Output: Nothing, kills the process 107*7836SJohn.Forte@Sun.COM 108*7836SJohn.Forte@Sun.COMfunction kill_scswitch 109*7836SJohn.Forte@Sun.COM{ 110*7836SJohn.Forte@Sun.COM dg=$1 111*7836SJohn.Forte@Sun.COM if [ -f /var/run/scnws/$dg.pid ] 112*7836SJohn.Forte@Sun.COM then 113*7836SJohn.Forte@Sun.COM for i in `cat /var/run/scnws/$dg.pid` 114*7836SJohn.Forte@Sun.COM do 115*7836SJohn.Forte@Sun.COM pid=$i 116*7836SJohn.Forte@Sun.COM kill -9 $pid 117*7836SJohn.Forte@Sun.COM done 118*7836SJohn.Forte@Sun.COM rm -f /var/run/scnws/$dg.pid 119*7836SJohn.Forte@Sun.COM fi 120*7836SJohn.Forte@Sun.COM} 121*7836SJohn.Forte@Sun.COM 122*7836SJohn.Forte@Sun.COM# Get the status of the resource group on this node, using scha commands. 123*7836SJohn.Forte@Sun.COM# Input: resource group - $1 124*7836SJohn.Forte@Sun.COM# Output: Status 125*7836SJohn.Forte@Sun.COM 126*7836SJohn.Forte@Sun.COMfunction get_rgstat 127*7836SJohn.Forte@Sun.COM{ 128*7836SJohn.Forte@Sun.COM rg=$1 129*7836SJohn.Forte@Sun.COM rgstat=`scha_resourcegroup_get -O RG_STATE -G $rg` 130*7836SJohn.Forte@Sun.COM} 131*7836SJohn.Forte@Sun.COM 132*7836SJohn.Forte@Sun.COM# This function is called in background from do_scswitch function, to 133*7836SJohn.Forte@Sun.COM# switch the resource group to this node, which is becoming primary for 134*7836SJohn.Forte@Sun.COM# the diskgroup. If the status of resource group is Offline, it will use 135*7836SJohn.Forte@Sun.COM# scswitch command to switch the resource group to this node. If it has 136*7836SJohn.Forte@Sun.COM# become Online, cleanup pid file. If it is Pending, the resource group 137*7836SJohn.Forte@Sun.COM# is in the state of becoming online, so wait for sometime to become Online.. 138*7836SJohn.Forte@Sun.COM# scswitch may fail, so the function retries $retry_num times, waiting for 139*7836SJohn.Forte@Sun.COM# $retry_interval seconds. 140*7836SJohn.Forte@Sun.COM# Input: resource group - $1, Diskgroup/Diskset - $2 141*7836SJohn.Forte@Sun.COM# Output: 0 - success, 1 - failure 142*7836SJohn.Forte@Sun.COM 143*7836SJohn.Forte@Sun.COMfunction switchfunc 144*7836SJohn.Forte@Sun.COM{ 145*7836SJohn.Forte@Sun.COM rg=$1 146*7836SJohn.Forte@Sun.COM dg=$2 147*7836SJohn.Forte@Sun.COM how_many=0 148*7836SJohn.Forte@Sun.COM sleep 2 149*7836SJohn.Forte@Sun.COM while [ $how_many != $retry_num ] 150*7836SJohn.Forte@Sun.COM do 151*7836SJohn.Forte@Sun.COM get_rgstat $rg 152*7836SJohn.Forte@Sun.COM case "$rgstat" in 153*7836SJohn.Forte@Sun.COM "ONLINE") 154*7836SJohn.Forte@Sun.COM rm -f /var/run/scnws/$dg.pid 155*7836SJohn.Forte@Sun.COM return 0 156*7836SJohn.Forte@Sun.COM ;; 157*7836SJohn.Forte@Sun.COM 158*7836SJohn.Forte@Sun.COM "OFFLINE") 159*7836SJohn.Forte@Sun.COM logger -p ${SYSLOG_FACILITY}.notice \ 160*7836SJohn.Forte@Sun.COM -t "NWS.[$ARGV0]" `gettext "scswitch of resource group"` "$rg" 161*7836SJohn.Forte@Sun.COM 162*7836SJohn.Forte@Sun.COM scswitch -z -g $rg -h $(hostname) 163*7836SJohn.Forte@Sun.COM retval=$? 164*7836SJohn.Forte@Sun.COM if [ $retval != 0 ] 165*7836SJohn.Forte@Sun.COM then 166*7836SJohn.Forte@Sun.COM sleep $retry_interval 167*7836SJohn.Forte@Sun.COM how_many=$(($how_many + 1)) 168*7836SJohn.Forte@Sun.COM fi 169*7836SJohn.Forte@Sun.COM ;; 170*7836SJohn.Forte@Sun.COM 171*7836SJohn.Forte@Sun.COM "PENDING_ONLINE") 172*7836SJohn.Forte@Sun.COM logger -p ${SYSLOG_FACILITY}.notice \ 173*7836SJohn.Forte@Sun.COM -t "NWS.[$ARGV0]" `gettext "pending online of resource group"` "$rg" 174*7836SJohn.Forte@Sun.COM sleep $retry_interval 175*7836SJohn.Forte@Sun.COM how_many=$(($how_many + 1)) 176*7836SJohn.Forte@Sun.COM ;; 177*7836SJohn.Forte@Sun.COM 178*7836SJohn.Forte@Sun.COM *) 179*7836SJohn.Forte@Sun.COM logger -p ${SYSLOG_FACILITY}.notice \ 180*7836SJohn.Forte@Sun.COM -t "NWS.[$ARGV0]" `gettext "Improper resource group status for Remote Mirror"` "$rgstat" 181*7836SJohn.Forte@Sun.COM rm -f /var/run/scnws/$dg.pid 182*7836SJohn.Forte@Sun.COM return 1 183*7836SJohn.Forte@Sun.COM ;; 184*7836SJohn.Forte@Sun.COM esac 185*7836SJohn.Forte@Sun.COM done 186*7836SJohn.Forte@Sun.COM logger -p ${SYSLOG_FACILITY}.err \ 187*7836SJohn.Forte@Sun.COM -t "NWS.[$ARGV0]" "Did not switch resource group for Remote Mirror. System Administrator intervention required" 188*7836SJohn.Forte@Sun.COM rm -f /var/run/scnws/$dg.pid 189*7836SJohn.Forte@Sun.COM return 1 190*7836SJohn.Forte@Sun.COM} 191*7836SJohn.Forte@Sun.COM 192*7836SJohn.Forte@Sun.COM 193*7836SJohn.Forte@Sun.COM# This function calls switchfunc function in background, to switch the 194*7836SJohn.Forte@Sun.COM# resource group for SNDR. It validates the diskgroup/diskset is configured 195*7836SJohn.Forte@Sun.COM# for SNDR, checks if the resource group is in Managed state etc. 196*7836SJohn.Forte@Sun.COM# If it detects a mis-configuration, it will disable SNDR for the 197*7836SJohn.Forte@Sun.COM# device group being processed. This is to prevent cluster hangs and panics. 198*7836SJohn.Forte@Sun.COM# 199*7836SJohn.Forte@Sun.COM# The ServicePaths extension property of HAStorage type resource or the 200*7836SJohn.Forte@Sun.COM# GlobalDevicePaths extension property of HAStoragePlus, both of which 201*7836SJohn.Forte@Sun.COM# specify the device group, serve as a link or mapping to retrieve the 202*7836SJohn.Forte@Sun.COM# resource group associated with the SNDR configured device group. 203*7836SJohn.Forte@Sun.COM# Switchfunc is called in the background to avoid the deadlock situation arising 204*7836SJohn.Forte@Sun.COM# out of switchover of resource group from within device group switchover. 205*7836SJohn.Forte@Sun.COM# 206*7836SJohn.Forte@Sun.COM# In run_reserve context, we are doing the device group switchover, trying to 207*7836SJohn.Forte@Sun.COM# bring it online on the node. Device group is not completely switched online, 208*7836SJohn.Forte@Sun.COM# until the calling script run_reserve returns. In the process, we are calling 209*7836SJohn.Forte@Sun.COM# the associated SNDR resource group switchover using scswitch command. 210*7836SJohn.Forte@Sun.COM# Resource group switchover will trigger the switchover of device group also. 211*7836SJohn.Forte@Sun.COM# 212*7836SJohn.Forte@Sun.COM# If resource group switchover is called in foreground, before the device 213*7836SJohn.Forte@Sun.COM# group has become online, then it will result in switching the device group 214*7836SJohn.Forte@Sun.COM# again, resulting in deadlock. Resource group can not become online until 215*7836SJohn.Forte@Sun.COM# the device group is online and the device group can not become online until the 216*7836SJohn.Forte@Sun.COM# script returns, causing this circular dependency resulting in deadlock. 217*7836SJohn.Forte@Sun.COM# 218*7836SJohn.Forte@Sun.COM# Calling the resource group switch in background allows current run_reserve 219*7836SJohn.Forte@Sun.COM# script to return immediately, allowing device group to become online. 220*7836SJohn.Forte@Sun.COM# If the device group is already online on the node, then the resource group 221*7836SJohn.Forte@Sun.COM# does not cause the device group switchover again. 222*7836SJohn.Forte@Sun.COM# 223*7836SJohn.Forte@Sun.COM# Input: Device group dg - $1 224*7836SJohn.Forte@Sun.COM# Output: 0 - success 225*7836SJohn.Forte@Sun.COM# 1 - either dg not applicable for SNDR or error 226*7836SJohn.Forte@Sun.COM# 2 - SNDR mis-configuration 227*7836SJohn.Forte@Sun.COM 228*7836SJohn.Forte@Sun.COMfunction do_scswitch 229*7836SJohn.Forte@Sun.COM{ 230*7836SJohn.Forte@Sun.COM dg=$1 231*7836SJohn.Forte@Sun.COM 232*7836SJohn.Forte@Sun.COM if [ ! -x /usr/cluster/bin/scha_resource_get \ 233*7836SJohn.Forte@Sun.COM -o ! -x /usr/cluster/bin/scha_resourcegroup_get ] 234*7836SJohn.Forte@Sun.COM then 235*7836SJohn.Forte@Sun.COM return 1 236*7836SJohn.Forte@Sun.COM fi 237*7836SJohn.Forte@Sun.COM 238*7836SJohn.Forte@Sun.COM# hard coded rg name from dg 239*7836SJohn.Forte@Sun.COM rgname="$dg-stor-rg" 240*7836SJohn.Forte@Sun.COM scha_resourcegroup_get -O rg_description -G $rgname > /dev/null 241*7836SJohn.Forte@Sun.COM if [ $? != 0 ] 242*7836SJohn.Forte@Sun.COM then 243*7836SJohn.Forte@Sun.COM# There is no device group configured in cluster for SNDR with this cluster tag 244*7836SJohn.Forte@Sun.COM return 1 245*7836SJohn.Forte@Sun.COM fi 246*7836SJohn.Forte@Sun.COM 247*7836SJohn.Forte@Sun.COM# Check the state of resource group 248*7836SJohn.Forte@Sun.COM 249*7836SJohn.Forte@Sun.COM get_rgstat $rgname 250*7836SJohn.Forte@Sun.COM if [ -z "$rgstat" \ 251*7836SJohn.Forte@Sun.COM -o "$rgstat" = "UNMANAGED" -o "$rgstat" = "ERROR_STOP_FAILED" ] 252*7836SJohn.Forte@Sun.COM then 253*7836SJohn.Forte@Sun.COM logger -p ${SYSLOG_FACILITY}.notice \ 254*7836SJohn.Forte@Sun.COM -t "NWS.[$ARGV0]" \ 255*7836SJohn.Forte@Sun.COM `gettext "Improper Remote Mirror resource group state"` "$rgstat" 256*7836SJohn.Forte@Sun.COM return 2 257*7836SJohn.Forte@Sun.COM fi 258*7836SJohn.Forte@Sun.COM 259*7836SJohn.Forte@Sun.COM# Check whether resources are of proper type and they are enabled 260*7836SJohn.Forte@Sun.COM 261*7836SJohn.Forte@Sun.COM rs_list=`scha_resourcegroup_get -O resource_list -G $rgname` 262*7836SJohn.Forte@Sun.COM if [ -z "$rs_list" ] 263*7836SJohn.Forte@Sun.COM then 264*7836SJohn.Forte@Sun.COM logger -p ${SYSLOG_FACILITY}.notice \ 265*7836SJohn.Forte@Sun.COM -t "NWS.[$ARGV0]" \ 266*7836SJohn.Forte@Sun.COM `gettext "No resources in Remote Mirror resource group <$rgname>"` 267*7836SJohn.Forte@Sun.COM return 2 268*7836SJohn.Forte@Sun.COM fi 269*7836SJohn.Forte@Sun.COM for rs in $rs_list 270*7836SJohn.Forte@Sun.COM do 271*7836SJohn.Forte@Sun.COM rs_type=`scha_resource_get -O type -R $rs -G $rgname | cut -d':' -f1` 272*7836SJohn.Forte@Sun.COM case "$rs_type" in 273*7836SJohn.Forte@Sun.COM SUNW.LogicalHostname) 274*7836SJohn.Forte@Sun.COM rs_enb=`scha_resource_get -O ON_OFF_SWITCH -R $rs -G $rgname` 275*7836SJohn.Forte@Sun.COM if [ "$rs_enb" = "ENABLED" ] 276*7836SJohn.Forte@Sun.COM then 277*7836SJohn.Forte@Sun.COM count_LogicalHostname=$(($count_LogicalHostname + 1)) 278*7836SJohn.Forte@Sun.COM fi 279*7836SJohn.Forte@Sun.COM ;; 280*7836SJohn.Forte@Sun.COM SUNW.HAStoragePlus) 281*7836SJohn.Forte@Sun.COM rs_enb=`scha_resource_get -O ON_OFF_SWITCH -R $rs -G $rgname` 282*7836SJohn.Forte@Sun.COM if [ "$rs_enb" = "ENABLED" ] 283*7836SJohn.Forte@Sun.COM then 284*7836SJohn.Forte@Sun.COM count_HAStoragePlus=$(($count_HAStoragePlus + 1)) 285*7836SJohn.Forte@Sun.COM fi 286*7836SJohn.Forte@Sun.COM ;; 287*7836SJohn.Forte@Sun.COM esac 288*7836SJohn.Forte@Sun.COM done 289*7836SJohn.Forte@Sun.COM if [ $count_LogicalHostname -lt 1 ] 290*7836SJohn.Forte@Sun.COM then 291*7836SJohn.Forte@Sun.COM logger -p ${SYSLOG_FACILITY}.notice \ 292*7836SJohn.Forte@Sun.COM -t "NWS.[$ARGV0]" `gettext "Missing Enabled Logical Host in resource group <$rgname> for Remote Mirror"` 293*7836SJohn.Forte@Sun.COM return 2 294*7836SJohn.Forte@Sun.COM elif [ $count_LogicalHostname -gt 1 ] 295*7836SJohn.Forte@Sun.COM then 296*7836SJohn.Forte@Sun.COM logger -p ${SYSLOG_FACILITY}.notice \ 297*7836SJohn.Forte@Sun.COM -t "NWS.[$ARGV0]" `gettext "Too Many Enabled Logical Host in resource group <$rgname> for Remote Mirror"` 298*7836SJohn.Forte@Sun.COM return 2 299*7836SJohn.Forte@Sun.COM fi 300*7836SJohn.Forte@Sun.COM 301*7836SJohn.Forte@Sun.COM if [ $count_HAStoragePlus -lt 1 ] 302*7836SJohn.Forte@Sun.COM then 303*7836SJohn.Forte@Sun.COM logger -p ${SYSLOG_FACILITY}.notice \ 304*7836SJohn.Forte@Sun.COM -t "NWS.[$ARGV0]" `gettext "Missing Enabled HAStoragePlus in resource group <$rgname> for Remote Mirror"` 305*7836SJohn.Forte@Sun.COM return 2 306*7836SJohn.Forte@Sun.COM elif [ $count_HAStoragePlus -gt 1 ] 307*7836SJohn.Forte@Sun.COM then 308*7836SJohn.Forte@Sun.COM logger -p ${SYSLOG_FACILITY}.notice \ 309*7836SJohn.Forte@Sun.COM -t "NWS.[$ARGV0]" `gettext "Too Many Enabled HAStoragePlus in resource group <$rgname> for Remote Mirror"` 310*7836SJohn.Forte@Sun.COM return 2 311*7836SJohn.Forte@Sun.COM fi 312*7836SJohn.Forte@Sun.COM 313*7836SJohn.Forte@Sun.COM# Invoke switchfunc to switch the resource group. 314*7836SJohn.Forte@Sun.COM 315*7836SJohn.Forte@Sun.COM switchfunc $rgname $dg & 316*7836SJohn.Forte@Sun.COM pid=$! 317*7836SJohn.Forte@Sun.COM mkdir -p /var/run/scnws/ 318*7836SJohn.Forte@Sun.COM rm -f /var/run/scnws/$dg.pid 319*7836SJohn.Forte@Sun.COM echo $pid > /var/run/scnws/$dg.pid 320*7836SJohn.Forte@Sun.COM 321*7836SJohn.Forte@Sun.COM return 0 322*7836SJohn.Forte@Sun.COM} 323*7836SJohn.Forte@Sun.COM 324*7836SJohn.Forte@Sun.COM 325*7836SJohn.Forte@Sun.COM# 326*7836SJohn.Forte@Sun.COM# Functions 327*7836SJohn.Forte@Sun.COM# 328*7836SJohn.Forte@Sun.COM 329*7836SJohn.Forte@Sun.COMusage() 330*7836SJohn.Forte@Sun.COM{ 331*7836SJohn.Forte@Sun.COM logger -p ${SYSLOG_FACILITY}.err \ 332*7836SJohn.Forte@Sun.COM -t "NWS.[$ARGV0]" "usage: $ARGV0 { start | stop } diskgroup" 333*7836SJohn.Forte@Sun.COM exit 1 334*7836SJohn.Forte@Sun.COM} 335*7836SJohn.Forte@Sun.COM 336*7836SJohn.Forte@Sun.COM 337*7836SJohn.Forte@Sun.COM# Input: arg1) $NWS_START_DIR - location of NWS scripts 338*7836SJohn.Forte@Sun.COM# arg2) start / stop 339*7836SJohn.Forte@Sun.COM# arg3 ) device group - $2 340*7836SJohn.Forte@Sun.COM# arg4) sndr_ena / sndr_dis 341*7836SJohn.Forte@Sun.COM# Output: Nothing. Log error if seen 342*7836SJohn.Forte@Sun.COM 343*7836SJohn.Forte@Sun.COMprocess_dir() 344*7836SJohn.Forte@Sun.COM{ 345*7836SJohn.Forte@Sun.COM typeset dir=$1 346*7836SJohn.Forte@Sun.COM typeset arg1=$2 347*7836SJohn.Forte@Sun.COM typeset dg=$3 348*7836SJohn.Forte@Sun.COM typeset arg2=$4 349*7836SJohn.Forte@Sun.COM typeset RDC=$dir/10rdc 350*7836SJohn.Forte@Sun.COM 351*7836SJohn.Forte@Sun.COM if [[ -d $dir ]] 352*7836SJohn.Forte@Sun.COM then 353*7836SJohn.Forte@Sun.COM for f in $dir/* 354*7836SJohn.Forte@Sun.COM do 355*7836SJohn.Forte@Sun.COM # process scripts in the directories in lexical order 356*7836SJohn.Forte@Sun.COM # note - no leading S or K unlike /etc/rc?.d/ 357*7836SJohn.Forte@Sun.COM 358*7836SJohn.Forte@Sun.COM if [ -s $f ] && [ $arg2 != "sndr_dis" ] 359*7836SJohn.Forte@Sun.COM then 360*7836SJohn.Forte@Sun.COM # run script and pipe output through 361*7836SJohn.Forte@Sun.COM # logger into syslog 362*7836SJohn.Forte@Sun.COM 363*7836SJohn.Forte@Sun.COM /usr/bin/ksh $f $arg1 $dg 2>&1 | 364*7836SJohn.Forte@Sun.COM logger -p ${SYSLOG_FACILITY}.notice \ 365*7836SJohn.Forte@Sun.COM -t "NWS.[${ARGV0}:$(basename $f)]" 366*7836SJohn.Forte@Sun.COM else 367*7836SJohn.Forte@Sun.COM # SNDR misconfigured - prevent start 368*7836SJohn.Forte@Sun.COM if [ -s $f ] && [ $f != $RDC ] 369*7836SJohn.Forte@Sun.COM then 370*7836SJohn.Forte@Sun.COM # run script and pipe output through 371*7836SJohn.Forte@Sun.COM # logger into syslog 372*7836SJohn.Forte@Sun.COM /usr/bin/ksh $f $arg1 $dg 2>&1 | 373*7836SJohn.Forte@Sun.COM logger -p ${SYSLOG_FACILITY}.notice \ 374*7836SJohn.Forte@Sun.COM -t "NWS.[${ARGV0}:$(basename $f)]" 375*7836SJohn.Forte@Sun.COM fi 376*7836SJohn.Forte@Sun.COM fi 377*7836SJohn.Forte@Sun.COM done 378*7836SJohn.Forte@Sun.COM else 379*7836SJohn.Forte@Sun.COM logger -p ${SYSLOG_FACILITY}.err \ 380*7836SJohn.Forte@Sun.COM -t "NWS.[$ARGV0]" "no directory: $dir" 381*7836SJohn.Forte@Sun.COM fi 382*7836SJohn.Forte@Sun.COM} 383*7836SJohn.Forte@Sun.COM 384*7836SJohn.Forte@Sun.COM 385*7836SJohn.Forte@Sun.COM# 386*7836SJohn.Forte@Sun.COM# main 387*7836SJohn.Forte@Sun.COM# 388*7836SJohn.Forte@Sun.COM 389*7836SJohn.Forte@Sun.COMif [ $# -ne 2 ] 390*7836SJohn.Forte@Sun.COMthen 391*7836SJohn.Forte@Sun.COM usage 392*7836SJohn.Forte@Sun.COM # not reached 393*7836SJohn.Forte@Sun.COMfi 394*7836SJohn.Forte@Sun.COM 395*7836SJohn.Forte@Sun.COM 396*7836SJohn.Forte@Sun.COMcase "$1" in 397*7836SJohn.Forte@Sun.COMstart) 398*7836SJohn.Forte@Sun.COM logger -p ${SYSLOG_FACILITY}.notice -t "NWS.[$ARGV0]" "starting: $ARGV0 $*" 399*7836SJohn.Forte@Sun.COM do_scswitch $2 400*7836SJohn.Forte@Sun.COM retval=$? 401*7836SJohn.Forte@Sun.COM if [ $retval == 2 ] 402*7836SJohn.Forte@Sun.COM then 403*7836SJohn.Forte@Sun.COM logger -p ${SYSLOG_FACILITY}.err \ 404*7836SJohn.Forte@Sun.COM -t "NWS.[$ARGV0]" "**FATAL ERROR** Remote Mirror is mis-configured and DISABLED for devicegroup <"$2"> " 405*7836SJohn.Forte@Sun.COM # Disable SNDR 406*7836SJohn.Forte@Sun.COM process_dir $NWS_START_DIR start "$2" sndr_dis 407*7836SJohn.Forte@Sun.COM else 408*7836SJohn.Forte@Sun.COM process_dir $NWS_START_DIR start "$2" sndr_ena 409*7836SJohn.Forte@Sun.COM fi 410*7836SJohn.Forte@Sun.COM ;; 411*7836SJohn.Forte@Sun.COMstop) 412*7836SJohn.Forte@Sun.COM logger -p ${SYSLOG_FACILITY}.notice -t "NWS.[$ARGV0]" "stopping: $ARGV0 $*" 413*7836SJohn.Forte@Sun.COM process_dir $NWS_STOP_DIR stop "$2" sndr_ena 414*7836SJohn.Forte@Sun.COM kill_scswitch $2 415*7836SJohn.Forte@Sun.COM ;; 416*7836SJohn.Forte@Sun.COM 417*7836SJohn.Forte@Sun.COM*) 418*7836SJohn.Forte@Sun.COM usage 419*7836SJohn.Forte@Sun.COM # not reached 420*7836SJohn.Forte@Sun.COM ;; 421*7836SJohn.Forte@Sun.COMesac 422*7836SJohn.Forte@Sun.COM 423*7836SJohn.Forte@Sun.COMlogger -p ${SYSLOG_FACILITY}.notice -t "NWS.[$ARGV0]" "completed: $ARGV0 $*" 424*7836SJohn.Forte@Sun.COM 425*7836SJohn.Forte@Sun.COMexit 0 426