4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
22 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 # Use is subject to license terms.
25 #######################################################################
27 # This file contains system setup requirements for scm.
29 # For systems before Solaris 10 it should be located in /etc/init.d
30 # directory with the following links:
32 # ln /etc/init.d/scm /etc/rc0.d/K84scm
33 # ln /etc/init.d/scm /etc/rc2.d/S002scm
35 # For Solaris 10 or later systems this script is run as part of SVC by
36 # svc.startd and should be located in /lib/svc/method
38 #USAGE="Usage: $0 { start | stop }
40 #######################################################################
43 DSCFG_DEPEND_NOCHK
="/tmp/.dscfgadm_pid"
44 OS_MINOR
=`/usr/bin/uname -r | /usr/bin/cut -d '.' -f2`
46 .
/lib
/svc
/share
/smf_include.sh
48 # Make sure prior SMF dependents are not 'online'
49 # $1 = name of SMF service to validate dependents
56 if [ $OS_MINOR -ge 11 ]
59 elif [ -f $DSCFG_DEPEND_NOCHK ]
61 for pid
in `pgrep dscfgadm`
63 if [ `grep -c $pid $DSCFG_DEPEND_NOCHK` -gt 0 ]
68 elif [ `ps -ef | grep preremove | grep -c SUNWscmu` -gt 0 ]
74 while [ $count -ne 0 ]
76 count
=`$SVCS -o STATE -D $1 2>>/dev/null | grep "^online" | wc -l`
79 # Output banner after waiting first 5 seconds
83 echo "Waiting for $1 dependents to be 'offline'"
84 $SVCS -D $1 2>>/dev
/null |
grep "^online"
87 # Has it been longer then 5 minutes? (60 * 5 secs.)
91 echo "Error: Failed waiting for $1 dependents to be 'offline'"
92 $SVCS -D $1 2>>/dev
/null |
grep "^online"
93 exit $SMF_EXIT_ERR_FATAL
96 # Now sleep, giving other services time to stop
99 times=`expr $times + 1`
107 CLINFO
=/usr
/sbin
/clinfo
112 DSCFG_LOCKDB
=/etc
/dscfg_lockdb
117 if [ ! -r /dev
/sdbc
]
123 if [ $?
-ne 0 ] ; then
124 # If the disable failed that means we have pinned data.
125 echo "Cache Not Deconfigured"
131 ps
-e |
grep -w nskernd
> /dev
/null
2>&1
132 if [ $?
-eq 0 ] ; then
133 # make sure that all data services are unloaded before stopping
134 # nskernd - cannot stop nskernd when its threads could be in use
135 # Note: sv is unloadable, but its threadset is shutdown in the
136 # final close(9e) call.
138 for m
in ste rdc rdcsrv ii sdbc
; do
139 mid
=`/usr/sbin/modinfo | grep -w $m | awk '{print $1}' -`
140 if [ -z "$mid" ] ; then
141 continue # not loaded
143 /usr
/sbin
/modunload
-i $mid > /dev
/null
2>&1
144 if [ $?
-ne 0 ] ; then
150 # kill nskernd if we can
151 pid
=`ps -e | grep -w nskernd | sed -e 's/^ *//' -e 's/ .*//'`
152 if [ $stop -eq 1 ] ; then
153 if [ -n "$pid" ] ; then
159 if [ -r /dev
/ncall
-a -x $ESMSCMLIB/ncalladm
]
161 $ESMSCMLIB/ncalladm
-d
167 pid
=`ps -e | grep -w dscfgloc | sed -e 's/^ *//' -e 's/ .*//'`
168 if [ -n "$pid" ] ; then
175 do_smf_depends
"system/nws_scm"
183 if [ -x $ESMSCMLIB/ncalladm
]
185 $ESMSCMLIB/ncalladm
-e
188 ps
-e |
grep -w nskernd
> /dev
/null
2>&1
189 if [ $?
-ne 0 ] ; then
191 if [ $?
-ne 0 ] ; then
192 echo "Error: Unable to start nskernd"
193 exit $SMF_EXIT_ERR_FATAL
200 ps
-e |
grep -w dscfgloc
> /dev
/null
2>&1
203 rm -f /var
/tmp
/.cfglockd.pid
205 # dscfglockd already running
212 # create or update the dscfg_lockdb file
215 # create clean tmpnodelist
216 NODELIST
=/tmp
/$$.dscfg_nodelist
217 rm -f $NODELIST >/dev
/null
2>&1
220 if [ -x /usr
/cluster
/bin
/scstat
]
222 # get valid names in cluster
223 /usr
/cluster
/bin
/scstat
-n |
grep node
: | \
224 awk '{print $3}' >> $NODELIST
225 if [ ! -f $DSCFG_LOCKDB ]
227 printf "In clustered environment.\n"
228 printf "creating per node dscfg_lockdb database"
229 printf " with following nodenames:\n"
231 cp $NODELIST $DSCFG_LOCKDB
233 # check if there are any changes
234 diff $NODELIST $DSCFG_LOCKDB > /dev
/null
237 printf "The cluster node names have "
238 printf "changed. Updating dscfg_lockdb "
240 printf "Previous node names:\n"
242 printf "New node names:\n"
245 cp $NODELIST $DSCFG_LOCKDB
249 # we're in a cluster, but scstat is not available
250 printf "In clustered environment.\n"
251 printf "Required configuration file, $DSCFG_LOCKDB\n"
252 printf "was not properly populated with the cluster "
253 printf "nodenames.\nThis file needs to be manually"
254 printf "updated with the cluster\nnodenames before "
255 printf "reboot. Refer to Sun Storage Availability\n"
256 printf "Suite Installation Guide for details.\n"
259 # clustered start of dscfglockd
260 if [ -f $DSCFG_LOCKDB ]
262 printf "Starting dscfglockd\n"
263 ${SCMLIB}/dscfglockd
-f $DSCFG_LOCKDB
265 printf "WARNING: Mis-Configuration of Availability "
266 printf "Suite for Sun Cluster\n"
267 printf "WARNING: Can't find configuration file for "
268 printf "dscfglockd\n"
284 # do nothing if we do not have a dscfg
285 if [ ! -f /etc
/dscfg_local
]
287 echo "Cannot find Availability Suite configuration location"
288 exit $SMF_EXIT_ERR_NOSMF
293 # dscfglockd -- locking must be present before any dscfg access
294 # nskernd -- starts infrastructure (nskernd, ncall).
295 # sdbc -- start the cache itself
336 if [ $USED = 0 ] ; then
340 if [ $ACTION = "start" ] ; then
342 elif [ $ACTION = "stop" ] ; then