stmsboot.sh (60fffc19b6d98cdde54f6ad4c249f6cd4560d04b) | stmsboot.sh (815dd9170b31c7359f1b3fbe11df4da223766647) |
---|---|
1#!/sbin/sh 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# --- 10 unchanged lines hidden (view full) --- 19# 20# CDDL HEADER END 21# 22# 23# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24# Use is subject to license terms. 25# 26#ident "%Z%%M% %I% %E% SMI" | 1#!/sbin/sh 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# --- 10 unchanged lines hidden (view full) --- 19# 20# CDDL HEADER END 21# 22# 23# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24# Use is subject to license terms. 25# 26#ident "%Z%%M% %I% %E% SMI" |
27# |
|
27 28PATH=/usr/bin:/usr/sbin:$PATH; export PATH 29STMSBOOTUTIL=/lib/mpxio/stmsboot_util 30STMSMETHODSCRIPT=/lib/svc/method/mpxio-upgrade 31KDRVCONF= 32DRVCONF= 33TMPDRVCONF= 34TMPDRVCONF_MPXIO_ENTRY= --- 12 unchanged lines hidden (view full) --- 47BOOTADM=/sbin/bootadm 48MOUNT=/usr/sbin/mount 49EGREP=/usr/bin/egrep 50GREP=/usr/bin/grep 51AWK=/usr/bin/awk 52SORT=/usr/bin/sort 53UNIQ=/usr/bin/uniq 54EXPR=/usr/bin/expr | 28 29PATH=/usr/bin:/usr/sbin:$PATH; export PATH 30STMSBOOTUTIL=/lib/mpxio/stmsboot_util 31STMSMETHODSCRIPT=/lib/svc/method/mpxio-upgrade 32KDRVCONF= 33DRVCONF= 34TMPDRVCONF= 35TMPDRVCONF_MPXIO_ENTRY= --- 12 unchanged lines hidden (view full) --- 48BOOTADM=/sbin/bootadm 49MOUNT=/usr/sbin/mount 50EGREP=/usr/bin/egrep 51GREP=/usr/bin/grep 52AWK=/usr/bin/awk 53SORT=/usr/bin/sort 54UNIQ=/usr/bin/uniq 55EXPR=/usr/bin/expr |
56SED=/usr/bin/sed 57SVCPROP=/usr/bin/svcprop 58SVCCFG=/usr/sbin/svccfg 59SVCS=/usr/bin/svcs 60SVCADM=/usr/sbin/svcadm |
|
55 56MACH=`/usr/bin/uname -p` 57BOOTENV_FILE=/boot/solaris/bootenv.rc 58 59CLIENT_TYPE_VHCI="/scsi_vhci.*/ssd@|/scsi_vhci.*/disk@" 60# The phci client type egrep string will change based on the 61# drivers which we are operating on, and the cpu architecture 62# and we call stmsboot_util -n -D $drv to get that string --- 71 unchanged lines hidden (view full) --- 134 135 if [ "x$cmd" = xupdate ]; then 136 gettext "\tUndo the modifications you made to STMS configuration.\n\tFor example undo any changes you made to " >> $RECOVERFILE 137 echo "/mnt$KDRVCONF." >> $RECOVERFILE 138 else 139 echo "\tcp /mnt${SAVEDIR}/$DRVCONF /mnt$KDRVCONF" >> $RECOVERFILE 140 fi 141 | 61 62MACH=`/usr/bin/uname -p` 63BOOTENV_FILE=/boot/solaris/bootenv.rc 64 65CLIENT_TYPE_VHCI="/scsi_vhci.*/ssd@|/scsi_vhci.*/disk@" 66# The phci client type egrep string will change based on the 67# drivers which we are operating on, and the cpu architecture 68# and we call stmsboot_util -n -D $drv to get that string --- 71 unchanged lines hidden (view full) --- 140 141 if [ "x$cmd" = xupdate ]; then 142 gettext "\tUndo the modifications you made to STMS configuration.\n\tFor example undo any changes you made to " >> $RECOVERFILE 143 echo "/mnt$KDRVCONF." >> $RECOVERFILE 144 else 145 echo "\tcp /mnt${SAVEDIR}/$DRVCONF /mnt$KDRVCONF" >> $RECOVERFILE 146 fi 147 |
142 if [ $1 -ne 0 ]; then | 148 if [ $1 -eq 1 ]; then |
143 echo "\tcp /mnt${SAVEDIR}/vfstab /mnt$VFSTAB" >> $RECOVERFILE 144 145 echo "repository /mnt/etc/svc/repository.db" > $SVCCFG_RECOVERY 146 echo "select $STMSINSTANCE" >> $SVCCFG_RECOVERY 147 echo "setprop general/enabled=false" >> $SVCCFG_RECOVERY 148 echo "exit" >> $SVCCFG_RECOVERY 149 | 149 echo "\tcp /mnt${SAVEDIR}/vfstab /mnt$VFSTAB" >> $RECOVERFILE 150 151 echo "repository /mnt/etc/svc/repository.db" > $SVCCFG_RECOVERY 152 echo "select $STMSINSTANCE" >> $SVCCFG_RECOVERY 153 echo "setprop general/enabled=false" >> $SVCCFG_RECOVERY 154 echo "exit" >> $SVCCFG_RECOVERY 155 |
150 echo "\t/usr/sbin/svccfg -f /mnt$SVCCFG_RECOVERY" >> $RECOVERFILE | 156 echo "\t$SVCCFG -f /mnt$SVCCFG_RECOVERY" >> $RECOVERFILE |
151 152 if [ "x$MACH" = "xi386" -a "x$new_bootpath" != "x" ]; then 153 echo "\tcp /mnt${SAVEDIR}/bootenv.rc /mnt$BOOTENV_FILE" >> $RECOVERFILE 154 fi 155 fi 156 157 rootdisk=`$MOUNT | $GREP "/ on " | cut -f 3 -d " "` 158 echo "\tumount /mnt\n\treboot\n\n${rootdisk} \c" >> $RECOVERFILE --- 17 unchanged lines hidden (view full) --- 176 "x$response" != xY ]; then 177 for d in $DRVLIST; do 178 TMPDRVCONF=/var/run/tmp.$d.conf.$$ 179 rm -f $TMPDRVCONF > /dev/null 2>&1 180 done; 181 return 0; 182 fi 183 | 157 158 if [ "x$MACH" = "xi386" -a "x$new_bootpath" != "x" ]; then 159 echo "\tcp /mnt${SAVEDIR}/bootenv.rc /mnt$BOOTENV_FILE" >> $RECOVERFILE 160 fi 161 fi 162 163 rootdisk=`$MOUNT | $GREP "/ on " | cut -f 3 -d " "` 164 echo "\tumount /mnt\n\treboot\n\n${rootdisk} \c" >> $RECOVERFILE --- 17 unchanged lines hidden (view full) --- 182 "x$response" != xY ]; then 183 for d in $DRVLIST; do 184 TMPDRVCONF=/var/run/tmp.$d.conf.$$ 185 rm -f $TMPDRVCONF > /dev/null 2>&1 186 done; 187 return 0; 188 fi 189 |
184 need_bootscript="" | 190 # set need_bootscript to the number of drivers that 191 # we support. 192 need_bootscript=`echo $SUPPORTED_DRIVERS|$AWK -F"|" '{print NF}'` |
185 186 if [ "x$cmd" = xenable -o "x$cmd" = xdisable ]; then 187 188 for d in $DRVLIST; do 189 DRVCONF=$d.conf 190 KDRVCONF=/kernel/drv/$d.conf 191 TMPDRVCONF=/var/run/tmp.$d.conf.$$ 192 193 cp $KDRVCONF $SAVEDIR | 193 194 if [ "x$cmd" = xenable -o "x$cmd" = xdisable ]; then 195 196 for d in $DRVLIST; do 197 DRVCONF=$d.conf 198 KDRVCONF=/kernel/drv/$d.conf 199 TMPDRVCONF=/var/run/tmp.$d.conf.$$ 200 201 cp $KDRVCONF $SAVEDIR |
194 cp $TMPDRVCONF $KDRVCONF 195 rm -f $TMPDRVCONF > /dev/null 2>&1 | 202 if [ -f $TMPDRVCONF ]; then 203 cp $TMPDRVCONF $KDRVCONF 204 rm -f $TMPDRVCONF 205 else 206 # if $TMPDRVCONF doesn't exist, then we 207 # haven't made any changes to it 208 continue; 209 fi |
196 197 # 198 # there is no need to update the system files in the following 199 # cases: 200 # - we are enabling mpxio and the system has no configured 201 # disks accessible by phci paths. 202 # - we are disabling mpxio and the system has no configured 203 # disks accessible by vhci paths. 204 # 205 | 210 211 # 212 # there is no need to update the system files in the following 213 # cases: 214 # - we are enabling mpxio and the system has no configured 215 # disks accessible by phci paths. 216 # - we are disabling mpxio and the system has no configured 217 # disks accessible by vhci paths. 218 # 219 |
206 build_parent_list $d; | 220 # Function to setup the CLIENT_TYPE_PHCI string based on 221 # the list of drivers that we're operating on. The variable 222 # depends upon the pathname of the parent node in the 223 # device tree, which can be different on x86/x64 and sparc. 224 225 CLIENT_TYPE_PHCI=`$STMSBOOTUTIL -D $d -n`; 226 |
207 if [ "x$CLIENT_TYPE_PHCI" = "x" ]; then 208 continue; 209 fi 210 211 if [ "x$cmd" = "xenable" ]; then 212 ls -l /dev/dsk/*s2 2> /dev/null | \ 213 $EGREP -s "$CLIENT_TYPE_PHCI" 214 else 215 ls -l /dev/dsk/*s2 2> /dev/null | \ 216 $EGREP -s "$CLIENT_TYPE_VHCI" 217 fi 218 219 if [ $? -ne 0 ]; then | 227 if [ "x$CLIENT_TYPE_PHCI" = "x" ]; then 228 continue; 229 fi 230 231 if [ "x$cmd" = "xenable" ]; then 232 ls -l /dev/dsk/*s2 2> /dev/null | \ 233 $EGREP -s "$CLIENT_TYPE_PHCI" 234 else 235 ls -l /dev/dsk/*s2 2> /dev/null | \ 236 $EGREP -s "$CLIENT_TYPE_VHCI" 237 fi 238 239 if [ $? -ne 0 ]; then |
220 need_bootscript="$need_bootscript $d" | 240 need_bootscript=`$EXPR $need_bootscript - 1` |
221 fi 222 done 223 fi 224 225 # if we're an x86/x64 machine and our bootpath is on fibrechannel 226 # then we cannot disable mpxio for that controller. Yet..... 227 # This code block is an ugly hack and when we either get full-time 228 # mpxio for all devices, or devfsadm gets re-written then we can --- 5 unchanged lines hidden (view full) --- 234 if [ ! -z "$FPBOOT" ]; then 235 NEWP=`/usr/bin/dirname $BOOTPATH` 236 NNEWP=`/usr/bin/dirname $NEWP` 237 238 # check that we haven't already got this entry 239 # in /kernel/drv/fp.conf. 240 241 EXISTP=`$GREP "^name.*$NNEWP" /kernel/drv/fp.conf` | 241 fi 242 done 243 fi 244 245 # if we're an x86/x64 machine and our bootpath is on fibrechannel 246 # then we cannot disable mpxio for that controller. Yet..... 247 # This code block is an ugly hack and when we either get full-time 248 # mpxio for all devices, or devfsadm gets re-written then we can --- 5 unchanged lines hidden (view full) --- 254 if [ ! -z "$FPBOOT" ]; then 255 NEWP=`/usr/bin/dirname $BOOTPATH` 256 NNEWP=`/usr/bin/dirname $NEWP` 257 258 # check that we haven't already got this entry 259 # in /kernel/drv/fp.conf. 260 261 EXISTP=`$GREP "^name.*$NNEWP" /kernel/drv/fp.conf` |
242# if [ -z "$EXISTP" ]; then | |
243 if [ $? != 0 ]; then 244 cat >>/kernel/drv/fp.conf << EOF 245# This entry must be the last one in the fp.conf file 246# to ensure that the boot path mpxio setting is not 247# accidentally overridden 248name="fp" parent="$NNEWP" port=0 mpxio-disable="no"; 249EOF 250 fi 251 fi 252 fi 253 | 262 if [ $? != 0 ]; then 263 cat >>/kernel/drv/fp.conf << EOF 264# This entry must be the last one in the fp.conf file 265# to ensure that the boot path mpxio setting is not 266# accidentally overridden 267name="fp" parent="$NNEWP" port=0 mpxio-disable="no"; 268EOF 269 fi 270 fi 271 fi 272 |
254 if [ -z "$need_bootscript" ]; then 255 need_bootscript=0 | 273 if [ $need_bootscript -gt 0 ]; then 274 need_bootscript=1 |
256 if [ "x$MACH" = "xi386" -a "x$new_bootpath" != "x" ]; then 257 #only update bootpath for x86. 258 cp $BOOTENV_FILE $SAVEDIR 259 /usr/sbin/eeprom bootpath=$new_bootpath 260 fi 261 # 262 # Enable the mpxio-upgrade service, but don't run it now. 263 # The service will run during the next reboot and will do 264 # the actual job of modifying the system files. 265 # | 275 if [ "x$MACH" = "xi386" -a "x$new_bootpath" != "x" ]; then 276 #only update bootpath for x86. 277 cp $BOOTENV_FILE $SAVEDIR 278 /usr/sbin/eeprom bootpath=$new_bootpath 279 fi 280 # 281 # Enable the mpxio-upgrade service, but don't run it now. 282 # The service will run during the next reboot and will do 283 # the actual job of modifying the system files. 284 # |
266 svcadm disable -t $STMSINSTANCE 267 svccfg -f - << EOF | 285 $SVCADM disable -t $STMSINSTANCE 286 $SVCCFG -f - << EOF |
268select $STMSINSTANCE 269setprop general/enabled = true 270EOF | 287select $STMSINSTANCE 288setprop general/enabled = true 289EOF |
290 else 291 need_bootscript=0 |
|
271 fi 272 273 build_recover $need_bootscript 274 275 if [ "x$MACH" = "xi386" ]; then 276 $BOOTADM update-archive 277 fi 278 --- 127 unchanged lines hidden (view full) --- 406# their argument list 407# 408 409emit_driver_warning_msg() { 410 411 # for each driver that we support, grab the list 412 # of controllers attached to the system. 413 | 292 fi 293 294 build_recover $need_bootscript 295 296 if [ "x$MACH" = "xi386" ]; then 297 $BOOTADM update-archive 298 fi 299 --- 127 unchanged lines hidden (view full) --- 427# their argument list 428# 429 430emit_driver_warning_msg() { 431 432 # for each driver that we support, grab the list 433 # of controllers attached to the system. 434 |
435 echo "" |
|
414 echo "WARNING: stmsboot operates on each supported multipath-capable controller" 415 echo " detected in a host. In your system, these controllers are" 416 | 436 echo "WARNING: stmsboot operates on each supported multipath-capable controller" 437 echo " detected in a host. In your system, these controllers are" 438 |
417 for WARNDRV in fp mpt; do 418 $GREP "$WARNDRV.$" /etc/path_to_inst | $AWK -F"\"" '{print "/devices"$2}' | 439 for WARNDRV in `echo $SUPPORTED_DRIVERS| $SED -e"s,|, ,g"`; do 440 for i in `$STMSBOOTUTIL -D $WARNDRV -n | $SED -e"s,|, ,g"`; do 441 $GREP "$i.*$WARNDRV.$" /etc/path_to_inst | $AWK -F"\"" '{print "/devices"$2}' 442 done; |
419 done; 420 421 echo "" 422 echo "If you do NOT wish to operate on these controllers, please quit stmsboot" 423 echo "and re-invoke with -D { fp | mpt } to specify which controllers you wish" 424 echo "to modify your multipathing configuration for." 425 | 443 done; 444 445 echo "" 446 echo "If you do NOT wish to operate on these controllers, please quit stmsboot" 447 echo "and re-invoke with -D { fp | mpt } to specify which controllers you wish" 448 echo "to modify your multipathing configuration for." 449 |
426 echo | 450 echo "" |
427 gettext "Do you wish to continue? [y/n] (default: y) " 1>&2 428 read response 429 | 451 gettext "Do you wish to continue? [y/n] (default: y) " 1>&2 452 read response 453 |
430 if [ "x$response" -ne "xY" -a "x$response" -ne "xy" ]; then | 454 if [ "x$response" != "xY" -a "x$response" != "xy" ]; then |
431 exit 432 fi 433 434} 435 | 455 exit 456 fi 457 458} 459 |
436# Function to setup the CLIENT_TYPE_PHCI string based on 437# the list of drivers that we're operating on. The variable 438# depends upon the pathname of the parent node in the 439# device tree, which can be different on x86/x64 and sparc. 440# Oh, if we only had OBP on x86/x64! 441build_parent_list() { 442 443 # stmsboot_util -n provides us with the name of the 444 # node containing "fp" or "sas-$d", and helpfully 445 # appends "/[ssd|sd]@" as appropriate 446 447 d=$1; 448 449 TLIST=`$STMSBOOTUTIL -D $d -n` 450 if [ "x$TLIST" != "x" ]; then 451 CLIENT_TYPE_PHCI="$TLIST|$CLIENT_TYPE_PHCI" 452 else 453 CLIENT_TYPE_PHCI="$CLIENT_TYPE_PHCI" 454 fi 455} 456 457 | |
458cmd=none 459 460# process options 461while getopts D:geduLl: c 462do 463 case $c in 464 e) setcmd enable;; 465 d) setcmd disable;; --- 30 unchanged lines hidden (view full) --- 496# just a sanity check 497if [ ! -f $STMSBOOTUTIL -o ! -f $STMSMETHODSCRIPT ]; then 498 fmt=`gettext "Can't find %s and/or %s"` 499 printf "$fmt\n" "$STMSBOOTUTIL" "$STMSMETHODSCRIPT" 1>&2 500 exit 1 501fi 502 503# If the old sun4u-specific SMF method is found, remove it | 460cmd=none 461 462# process options 463while getopts D:geduLl: c 464do 465 case $c in 466 e) setcmd enable;; 467 d) setcmd disable;; --- 30 unchanged lines hidden (view full) --- 498# just a sanity check 499if [ ! -f $STMSBOOTUTIL -o ! -f $STMSMETHODSCRIPT ]; then 500 fmt=`gettext "Can't find %s and/or %s"` 501 printf "$fmt\n" "$STMSBOOTUTIL" "$STMSMETHODSCRIPT" 1>&2 502 exit 1 503fi 504 505# If the old sun4u-specific SMF method is found, remove it |
504/usr/sbin/svccfg -s "platform/sun4u/mpxio-upgrade:default" < /dev/null > /dev/null 2>&1 505if [ $? -ne 0 ]; then 506 /usr/sbin/svccfg delete "platform/sun4u/mpxio-upgrade:default" > /dev/null 2>&1 | 506$SVCCFG -s "platform/sun4u/mpxio-upgrade:default" < /dev/null > /dev/null 2>&1 507if [ $? -eq 0 ]; then 508 $SVCCFG delete "platform/sun4u/mpxio-upgrade:default" > /dev/null 2>&1 |
507fi 508 509# now import the new service, if necessary | 509fi 510 511# now import the new service, if necessary |
510/usr/bin/svcprop -q $STMSINSTANCE < /dev/null > /dev/null 2>&1 | 512$SVCPROP -q $STMSINSTANCE < /dev/null > /dev/null 2>&1 |
511if [ $? -ne 0 ]; then 512 if [ -f /var/svc/manifest/system/device/mpxio-upgrade.xml ]; then | 513if [ $? -ne 0 ]; then 514 if [ -f /var/svc/manifest/system/device/mpxio-upgrade.xml ]; then |
513 /usr/sbin/svccfg import /var/svc/manifest/system/device/mpxio-upgrade.xml | 515 $SVCCFG import /var/svc/manifest/system/device/mpxio-upgrade.xml |
514 if [ $? -ne 0 ]; then 515 fmt=`gettext "Unable to import %s service"` 516 printf "$fmt\n" "$STMSINSTANCE" 1>&2 517 exit 1 518 else 519 fmt=`gettext "Service %s imported successfully, continuing"` 520 printf "$fmt\n" "$STMSINSTANCE" 1>&2 521 fi --- 9 unchanged lines hidden (view full) --- 531 # The bootup script doesn't work on cache-only-clients as the script 532 # is executed before the plumbing for cachefs mounting of root is done. 533 # 534 if $MOUNT -v | $EGREP -s " on / type (nfs|cachefs) "; then 535 gettext "This command option is not supported on systems with nfs or cachefs mounted root filesystem.\n" 1>&2 536 exit 1 537 fi 538 | 516 if [ $? -ne 0 ]; then 517 fmt=`gettext "Unable to import %s service"` 518 printf "$fmt\n" "$STMSINSTANCE" 1>&2 519 exit 1 520 else 521 fmt=`gettext "Service %s imported successfully, continuing"` 522 printf "$fmt\n" "$STMSINSTANCE" 1>&2 523 fi --- 9 unchanged lines hidden (view full) --- 533 # The bootup script doesn't work on cache-only-clients as the script 534 # is executed before the plumbing for cachefs mounting of root is done. 535 # 536 if $MOUNT -v | $EGREP -s " on / type (nfs|cachefs) "; then 537 gettext "This command option is not supported on systems with nfs or cachefs mounted root filesystem.\n" 1>&2 538 exit 1 539 fi 540 |
541 # if the user has left the system with the mpxio-upgrade service 542 # in a temporarily disabled state (ie, service is armed for the next 543 # reboot), then let them know. We need to ensure that the system is 544 # is in a sane state before allowing any further invocations, so 545 # try to get the system admin to do so 546 547 ISARMED=`$SVCS -l $STMSINSTANCE |$GREP "enabled.*temporary"` 548 if [ $? -eq 0 ]; then 549 echo "" 550 echo "You need the reboot the system in order to complete" 551 echo "the previous invocation of stmsboot." 552 echo "" 553 echo "Do you wish to reboot the system now? (y/n, default y) \c" 554 read response 555 556 if [ "x$response" = "xY" -o "x$response" = "xy" ]; then 557 /usr/sbin/reboot 558 else 559 /bin/echo "" 560 /bin/echo "Please reboot this system before continuing" 561 /bin/echo "" 562 exit 1 563 fi 564 fi 565 |
|
539 if [ -d $SAVEDIR ]; then 540 # 541 # keep a copy of the last saved files, useful for manual 542 # recovery in case of a problem. 543 # 544 for d in $DRVLIST; do 545 DRVCONF=$d.conf 546 KDRVCONF=/kernel/drv/$d.conf --- 68 unchanged lines hidden --- | 566 if [ -d $SAVEDIR ]; then 567 # 568 # keep a copy of the last saved files, useful for manual 569 # recovery in case of a problem. 570 # 571 for d in $DRVLIST; do 572 DRVCONF=$d.conf 573 KDRVCONF=/kernel/drv/$d.conf --- 68 unchanged lines hidden --- |