1 #!/sbin/sh -p
   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 #
   9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10 # or http://www.opensolaris.org/os/licensing.
  11 # See the License for the specific language governing permissions
  12 # and limitations under the License.
  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #
  22 #
  23 # Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  24 #
  25 #
  26 PATH=/usr/bin:/usr/sbin:$PATH; export PATH
  27 STMSBOOTUTIL=/lib/mpxio/stmsboot_util
  28 STMSMETHODSCRIPT=/lib/svc/method/mpxio-upgrade
  29 KDRVCONF=
  30 DRVCONF=
  31 TMPDRVCONF=
  32 TMPDRVCONF_MPXIO_ENTRY=
  33 TMPDRVCONF_SATA_ENTRY=
  34 DRVLIST=
  35 GUID=
  36 VFSTAB=/etc/vfstab
  37 SAVEDIR=/etc/mpxio
  38 BOOTDEVICES=$SAVEDIR/boot-devices
  39 RECOVERFILE=$SAVEDIR/recover_instructions
  40 SVCCFG_RECOVERY=$SAVEDIR/svccfg_recover
  41 SUPPORTED_DRIVERS="fp|mpt|mpt_sas|pmcs"
  42 USAGE=`gettext "Usage: stmsboot [-D $SUPPORTED_DRIVERS] -e | -d | -u | -L | -l controller_number"`
  43 TEXTDOMAIN=SUNW_OST_OSCMD
  44 export TEXTDOMAIN
  45 STMSINSTANCE=svc:system/device/mpxio-upgrade:default
  46 FASTBOOTINSTANCE=svc:system/boot-config:default
  47 STMSBOOT=/usr/sbin/stmsboot
  48 BOOTADM=/sbin/bootadm
  49 MOUNT=/usr/sbin/mount
  50 EEPROM=/usr/sbin/eeprom
  51 EGREP=/usr/bin/egrep
  52 GREP=/usr/bin/grep
  53 AWK=/usr/bin/awk
  54 CP=/usr/bin/cp
  55 DF=/usr/bin/df
  56 LS=/usr/bin/ls
  57 MV=/usr/bin/mv
  58 RM=/usr/bin/rm
  59 SORT=/usr/bin/sort
  60 UNIQ=/usr/bin/uniq
  61 EXPR=/usr/bin/expr
  62 MKDIR=/usr/bin/mkdir
  63 REBOOT=/usr/sbin/reboot
  64 SED=/usr/bin/sed
  65 SVCPROP=/usr/bin/svcprop
  66 SVCCFG=/usr/sbin/svccfg
  67 SVCS=/usr/bin/svcs
  68 SVCADM=/usr/sbin/svcadm
  69 
  70 NOW=`/usr/bin/date +%G%m%d_%H%M`
  71 MACH=`/usr/bin/uname -p`
  72 BOOTENV_FILE=bootenv.rc
  73 reboot_needed=0
  74 new_bootpath=""
  75 CLIENT_TYPE_PHCI=""
  76 CLIENT_TYPE_VHCI="/scsi_vhci"
  77 
  78 #
  79 # Copy all entries (including comments) from source driver.conf
  80 # to destination driver.conf except those entries which contain
  81 # the mpxio-disable property.
  82 # Take into consideration entries that spawn more than one line.
  83 #
  84 # $1    source driver.conf file
  85 # $2    destination driver.conf file
  86 #
  87 # Returns 0 on success, non zero on failure.
  88 #
  89 delete_mpxio_disable_entries()
  90 {
  91         # be careful here, we've got embedded \t characters
  92         # in sed's pattern space.
  93         $SED '
  94                 /^[     ]*#/{ p
  95                               d
  96                             }
  97                 s/[     ]*$//
  98                 /^$/{ p
  99                       d
 100                     }
 101                 /mpxio-disable[         ]*=.*;$/{ w '$3'
 102                                                   d
 103                                                 }
 104                 /disable-sata-mpxio[    ]*=.*;$/{ w '$4'
 105                                                   d
 106                                                 }
 107                 /;$/{ p
 108                       d
 109                     }
 110                 :rdnext
 111                 N
 112                 s/[     ]*$//
 113                 /[^;]$/b rdnext
 114                 /mpxio-disable[         ]*=/{ s/\n/ /g
 115                                               w '$3'
 116                                               d
 117                                             }
 118                 ' $1 > $2
 119 
 120         return $?
 121 }
 122 
 123 #
 124 # backup the last saved copy of the specified files.
 125 # $*    files to backup
 126 #
 127 backup_lastsaved()
 128 {
 129         for file in $*
 130         do
 131                 newfile=`basename $file`
 132                 $CP $file $SAVEDIR/$newfile.$cmd.$NOW
 133         done
 134 }
 135 
 136 #
 137 # build recover instructions
 138 #
 139 # $1    1 to include boot script in the instructions
 140 #       0 otherwise
 141 #
 142 build_recover()
 143 {
 144         gettext "Instructions to recover your previous STMS configuration (if in case the system does not boot):\n\n" > $RECOVERFILE
 145         echo "\tboot net \c"  >> $RECOVERFILE
 146         gettext "(or from a cd/dvd/another disk)\n" >> $RECOVERFILE
 147         echo "\tfsck <your-root-device>" >> $RECOVERFILE
 148         echo "\tmount <your-root-device> /mnt" >> $RECOVERFILE
 149 
 150         if [ "$cmd" = "update" ]; then
 151                 gettext "\tUndo the modifications you made to STMS configuration.\n\tFor example undo any changes you made to " >> $RECOVERFILE
 152                 echo "/mnt$KDRVCONF." >> $RECOVERFILE
 153         else
 154                 echo "\tcp /mnt${SAVEDIR}/$DRVCONF.$cmd.$NOW /mnt$KDRVCONF" >> $RECOVERFILE
 155         fi
 156 
 157         if [ $1 -eq 1 ]; then
 158                 echo "\tcp /mnt${SAVEDIR}/vfstab.$cmd.$NOW /mnt$VFSTAB" >> $RECOVERFILE
 159 
 160                 echo "repository /mnt/etc/svc/repository.db" > $SVCCFG_RECOVERY
 161                 echo "select $STMSINSTANCE" >> $SVCCFG_RECOVERY
 162                 echo "setprop general/enabled=false" >> $SVCCFG_RECOVERY
 163                 echo "exit" >> $SVCCFG_RECOVERY
 164 
 165                 echo "\t$SVCCFG -f /mnt$SVCCFG_RECOVERY" >> $RECOVERFILE
 166 
 167                 if [ -n "$new_bootpath" -a "$MACH" = "i386" ]; then
 168                         echo "\tcp /mnt${SAVEDIR}/bootenv.rc.$cmd.$NOW /mnt/boot/solaris/$BOOTENV_FILE" >> $RECOVERFILE
 169                 fi
 170         fi
 171 
 172         rootdisk=`$MOUNT | $GREP "/ on " | cut -f 3 -d " "`
 173         echo "\tumount /mnt\n\treboot\n\n${rootdisk} \c" >> $RECOVERFILE
 174         gettext "was your root device,\nbut it could be named differently after you boot net.\n" >> $RECOVERFILE
 175 }
 176 
 177 
 178 #
 179 # Arrange for /etc/vfstab and dump configuration to be updated
 180 # during the next reboot. If the cmd is "enable" or "disable", copy
 181 # $TMPDRVCONF to $KDRVCONF.
 182 #
 183 # Returns 0 on success, 1 on failure.
 184 #
 185 update_sysfiles()
 186 {
 187 
 188         gettext "WARNING: This operation will require a reboot.\n"
 189         gettext "Do you want to continue ? [y/n] (default: y) "
 190         read response
 191 
 192         if [ -n "$response" -a "$response" != "y" -a \
 193             "$response" != "Y" ]; then
 194                 for d in $DRVLIST; do
 195                         TMPDRVCONF=/var/run/tmp.$d.conf.$$
 196                         $RM -f $TMPDRVCONF > /dev/null 2>&1
 197                 done;
 198                 return 0;
 199         fi
 200 
 201         # set need_bootscript to the number of drivers that
 202         # we support.
 203         need_bootscript=`echo $SUPPORTED_DRIVERS|$AWK -F"|" '{print NF}'`
 204 
 205         if [ "$cmd" = "enable" -o "$cmd" = "disable" ]; then
 206 
 207                 for d in $DRVLIST; do
 208                         DRVCONF=$d.conf
 209                         KDRVCONF=/kernel/drv/$d.conf
 210                         TMPDRVCONF=/var/run/tmp.$d.conf.$$
 211 
 212                         $CP $KDRVCONF $SAVEDIR/`basename $KDRVCONF`.$cmd.$NOW
 213                         if [ -f $TMPDRVCONF ]; then
 214                                 $CP $TMPDRVCONF $KDRVCONF
 215                                 $RM -f $TMPDRVCONF
 216                         else
 217                                 # if $TMPDRVCONF doesn't exist, then we
 218                                 # haven't made any changes to it
 219                                 continue;
 220                         fi
 221 
 222                         #
 223                         # there is no need to update the system files in the following
 224                         # cases:
 225                         # - we are enabling mpxio and the system has no configured
 226                         #   disks accessible by phci paths.
 227                         # - we are disabling mpxio and the system has no configured
 228                         #   disks accessible by vhci paths.
 229                         #
 230 
 231                         # Function to setup the CLIENT_TYPE_PHCI string based on
 232                         # the list of drivers that we're operating on. The variable
 233                         # depends upon the pathname of the parent node in the 
 234                         # device tree, which can be different on x86/x64 and sparc.
 235 
 236                         CLIENT_TYPE_PHCI=`$STMSBOOTUTIL -D $d -N`;
 237 
 238                         if [ -z "$CLIENT_TYPE_PHCI" ]; then
 239                                 continue;
 240                         fi
 241 
 242                         if [ "$cmd" = "enable" ]; then
 243                                 $LS -l /dev/dsk/*s2 2> /dev/null | \
 244                                     $EGREP -s "$CLIENT_TYPE_PHCI"
 245                         else
 246                                 $LS -l /dev/dsk/*s2 2> /dev/null | \
 247                                     $EGREP -s "$CLIENT_TYPE_VHCI"
 248                         fi
 249 
 250                         if [ $? -ne 0 ]; then
 251                                 need_bootscript=`$EXPR $need_bootscript - 1`
 252                         fi
 253                 done
 254         fi
 255 
 256         if [ $need_bootscript -gt 0 ]; then
 257                 need_bootscript=1
 258                 if [  -n "$new_bootpath" -a "$MACH" = "i386" ]; then
 259                         #only update bootpath for x86.
 260                         $CP /boot/solaris/$BOOTENV_FILE $SAVEDIR/$BOOTENV_FILE.$cmd.$NOW
 261                         $EEPROM bootpath="$new_bootpath"
 262                 fi
 263 
 264                 if [ "$MACH" = "i386" ]; then
 265                         # Disable Fast Reboot temporarily for the next reboot only.
 266                         HASZFSROOT=`$DF -g / |$GREP zfs`
 267                         if [ -n "$HASZFSROOT" ]; then
 268                                 $SVCCFG -s $FASTBOOTINSTANCE addpg config_ovr application P > /dev/null 2>&1
 269                                 $SVCCFG -s $FASTBOOTINSTANCE \
 270                                     setprop config_ovr/fastreboot_default=boolean:\"false\"
 271                                 $SVCCFG -s $FASTBOOTINSTANCE \
 272                                     setprop config_ovr/fastreboot_onpanic=boolean:\"false\"
 273                                 $SVCADM refresh $FASTBOOTINSTANCE 
 274                         fi
 275                 fi
 276 
 277                 # Enable the mpxio-upgrade service for the reboot
 278                 $SVCADM disable -t $STMSINSTANCE
 279                 $SVCCFG -s $STMSINSTANCE "setprop general/enabled=true"
 280         else
 281                 need_bootscript=0
 282         fi
 283 
 284         build_recover $need_bootscript
 285 
 286         if [ "$MACH" = "i386" ]; then
 287                 $BOOTADM update-archive
 288         fi
 289 
 290         gettext "The changes will come into effect after rebooting the system.\nReboot the system now ? [y/n] (default: y) "
 291         read response
 292 
 293         if [ -z "$response" -o "$response" = "y" -o \
 294             "$response" = "Y" ]; then
 295                 $REBOOT
 296         fi
 297 
 298         return 0
 299 }
 300 
 301 
 302 #
 303 # Enable or disable mpxio as specified by the cmd.
 304 # Returns 0 on success, 1 on failure.
 305 #
 306 # Args: $cmd = {enable | disable}
 307 #       $d = {fp | mpt | mpt_sas | pmcs}
 308 #
 309 # the global variable $DRVLIST is used
 310 #
 311 configure_mpxio()
 312 {
 313         # be careful here, we've got embedded \t characters
 314         # in sed's pattern space.
 315         mpxiodisableno='mpxio-disable[  ]*=[    ]*"no"[         ]*;'
 316         mpxiodisableyes='mpxio-disable[         ]*=[    ]*"yes"[        ]*;'
 317         satadisableno='disable-sata-mpxio[      ]*=[    ]*"no"[         ]*;'
 318         satadisableyes='disable-sata-mpxio[     ]*=[    ]*"yes"[        ]*;'
 319 
 320         if [ "$cmd" = "enable" ]; then
 321                 mpxiodisable_cur_entry=$mpxiodisableyes
 322                 satadisable_cur_entry=$satadisableyes
 323                 propval=no
 324                 msg=`gettext "STMS already enabled"`
 325         else
 326                 mpxiodisable_cur_entry=$mpxiodisableno
 327                 satadisable_cur_entry=$satadisableno
 328                 propval=yes
 329                 msg=`gettext "STMS already disabled"`
 330         fi
 331 
 332         DRVCONF=$d.conf
 333         KDRVCONF=/kernel/drv/$d.conf
 334         TMPDRVCONF=/var/run/tmp.$d.conf.$$
 335         TMPDRVCONF_MPXIO_ENTRY=/var/run/tmp.$d.conf.mpxioentry.$$;
 336         TMPDRVCONF_SATA_ENTRY=/var/run/tmp.$d.conf.sataentry.$$;
 337 
 338         if delete_mpxio_disable_entries $KDRVCONF $TMPDRVCONF $TMPDRVCONF_MPXIO_ENTRY $TMPDRVCONF_SATA_ENTRY; then
 339 
 340                 if [ -s $TMPDRVCONF_MPXIO_ENTRY ]; then
 341                         # $DRVCONF does have mpxiodisable entries
 342                         $EGREP -s "$mpxiodisable_cur_entry" $TMPDRVCONF_MPXIO_ENTRY
 343                         if [ $? -eq 0 ]; then
 344                                 reboot_needed=`$EXPR $reboot_needed + 1`
 345                         else
 346                                 # if all mpxiodisable entries are no/yes for
 347                                 # enable/disable mpxio, notify the user
 348                                 $EGREP -s "$satadisable_cur_entry" $TMPDRVCONF_SATA_ENTRY
 349                                 if [ $? -eq 0 -a "$d" = "mpt" ]; then
 350                                         reboot_needed=`$EXPR $reboot_needed + 1`
 351                                 else
 352                                         $RM -f $TMPDRVCONF $TMPDRVCONF_MPXIO_ENTRY $TMPDRVCONF_SATA_ENTRY > /dev/null 2>&1
 353                                         return 0;
 354                                 fi
 355                         fi
 356 
 357                         # If mpxiodisable entries do not exist, always continue update
 358                 fi
 359         else
 360                 $RM -f $TMPDRVCONF $TMPDRVCONF_MPXIO_ENTRY $TMPDRVCONF_SATA_ENTRY > /dev/null 2>&1
 361                 gettext "failed to update " 1>&2
 362                 echo "$KDRVCONF." 1>&2 
 363                 gettext "No changes were made to your STMS configuration.\n" 1>&2
 364                 return 1
 365         fi
 366 
 367         rm $TMPDRVCONF_MPXIO_ENTRY $TMPDRVCONF_SATA_ENTRY > /dev/null 2>&1
 368         echo "mpxio-disable=\"${propval}\";" >> $TMPDRVCONF
 369         if [ "$d" = "mpt" ]; then
 370                 echo "disable-sata-mpxio=\"${propval}\";" >> $TMPDRVCONF
 371         fi
 372 
 373 }
 374 
 375 setcmd()
 376 {
 377         if [ "$cmd" = "none" ]; then
 378                 cmd=$1
 379         else
 380                 echo "$USAGE" 1>&2
 381                 exit 2
 382         fi
 383 }
 384 
 385 #
 386 # Need to update bootpath on x86 if boot system from FC disk
 387 # Only update bootpath here when mpxio is enabled
 388 # If mpxio is currently disabled, then we'll update bootpath in the
 389 # mpxio-upgrade service method on reboot.
 390 #
 391 
 392 get_newbootpath_for_stmsdev() {
 393         if [ "$cmd" = "enable" ]; then
 394                 return 0
 395         fi
 396 
 397         cur_bootpath=`$STMSBOOTUTIL -b`
 398         if [ $? != 0 ]; then
 399                 return 1
 400         fi
 401 
 402         # Since on x64 platforms the eeprom command doesn't update the
 403         # kernel, the file /boot/solaris/bootenv.rc and the kernel's
 404         # bootpath variable have a good chance of differing. We do some
 405         # extra handwaving to get the correct bootpath variable setting. 
 406 
 407         ONDISKVER=`$AWK '/bootpath/ {print $3}' /boot/solaris/bootenv.rc|\
 408                 $SED -e"s,',,g"`
 409         if [ "$ONDISKVER" != "$cur_bootpath" ]; then
 410                 cur_bootpath="$ONDISKVER"
 411         fi
 412 
 413         NEWBOOTPATH=""
 414         for path in $cur_bootpath; do
 415                 mapped=`$STMSBOOTUTIL -p $path`
 416                 if [ "$mapped" != "NOT_MAPPED" ]; then
 417                         if [ "$mapped" != "$path" ]; then
 418                                 NEWBOOTPATH=`echo "$path " | \
 419                                    $SED -e"s|$path|$mapped|"`" $NEWBOOTPATH"
 420                         else
 421                                 NEWBOOTPATH="$NEWBOOTPATH $path"
 422                         fi
 423                 fi
 424         done
 425         # now strip off leading and trailing space chars
 426         new_bootpath=`echo $NEWBOOTPATH`
 427         return 0
 428 }
 429 
 430 #
 431 # Emit a warning message to the user that by default we
 432 # operate on all multipath-capable controllers that are
 433 # attached to the system, and that if they want to operate
 434 # on only a specific controller type (fp|mpt|mpt_sas|pmcs|....) then 
 435 # they need to re-invoke stmsboot with "-D $driver" in
 436 # their argument list
 437 #
 438 
 439 emit_driver_warning_msg() {
 440 
 441         # for each driver that we support, grab the list
 442         # of controllers attached to the system.
 443 
 444         echo ""
 445         gettext "WARNING: stmsboot operates on each supported multipath-capable controller\n"
 446         gettext "         detected in a host. In your system, these controllers are\n\n"
 447 
 448         for WARNDRV in `echo $SUPPORTED_DRIVERS| $SED -e"s,|, ,g"`; do
 449                 $STMSBOOTUTIL -D $WARNDRV -n
 450         done;
 451         
 452         echo ""
 453         gettext "If you do NOT wish to operate on these controllers, please quit stmsboot\n"
 454         gettext "and re-invoke with -D { fp | mpt | mpt_sas | pmcs} to specify which controllers you wish\n"
 455         gettext "to modify your multipathing configuration for.\n"
 456 
 457         echo ""
 458         gettext "Do you wish to continue? [y/n] (default: y) " 
 459         read response
 460 
 461         if [ -n "$response" -a "$response" != "Y" -a \
 462             "$response" != "y" ]; then
 463                 exit
 464         fi
 465 }
 466 
 467 
 468 #
 469 #
 470 # main starts here
 471 #
 472 
 473 cmd=none
 474 # process options
 475 while getopts D:geduLl: c
 476 do
 477         case $c in
 478         e)      setcmd enable;;
 479         d)      setcmd disable;;
 480         u)      setcmd update;;
 481         L)      setcmd listall;;
 482         l)      setcmd list
 483                 controller=$OPTARG;;
 484         D)      DRV=$OPTARG;;
 485         g)      GUID="-g";;
 486         \?)     echo "$USAGE" 1>&2
 487                 exit 2;;
 488         esac
 489 done
 490 
 491 if [ "$cmd" = "none" ]; then
 492         echo "$USAGE" 1>&2
 493         exit 2
 494 fi
 495 
 496 if [ -z "$DRV" ]; then
 497         DRVLIST="fp mpt mpt_sas pmcs"
 498 else
 499         DRVLIST=$DRV
 500 fi
 501 
 502 USERID=`id | $EGREP "uid=0"`
 503 if [ -z "$USERID" ]; then
 504         gettext "You must be super-user to run this script.\n" 1>&2
 505         exit 1
 506 fi
 507 
 508 # just a sanity check
 509 if [ ! -f $STMSBOOTUTIL -o ! -f $STMSMETHODSCRIPT ]; then
 510         fmt=`gettext "Can't find %s and/or %s"`
 511         printf "$fmt\n" "$STMSBOOTUTIL" "$STMSMETHODSCRIPT" 1>&2
 512         exit 1
 513 fi
 514 
 515 # If the old sun4u-specific SMF method is found, remove it
 516 $SVCCFG -s "platform/sun4u/mpxio-upgrade:default" < /dev/null > /dev/null 2>&1
 517 if [ $? -eq 0 ]; then
 518         $SVCCFG delete "platform/sun4u/mpxio-upgrade:default" > /dev/null 2>&1
 519 fi
 520 
 521 # now import the new service, if necessary
 522 $SVCPROP -q $STMSINSTANCE < /dev/null > /dev/null 2>&1
 523 if [ $? -ne 0 ]; then
 524         if [ -f /lib/svc/manifest/system/device/mpxio-upgrade.xml ]; then
 525                 $SVCCFG import /lib/svc/manifest/system/device/mpxio-upgrade.xml
 526                 if [ $? -ne 0 ]; then
 527 
 528                         fmt=`gettext "Unable to import the %s service"`
 529                         printf "$fmt\n" "$STMSINSTANCE" 1>&2
 530                         exit 1
 531                 else
 532                         fmt=`gettext "Service %s imported successfully, continuing"`
 533                         printf "$fmt\n" "$STMSINSTANCE" 1>&2
 534                 fi
 535         else
 536                 fmt=`gettext "Service %s does not exist on this host"`
 537                 printf "$fmt\n" "$STMSINSTANCE" 1>&2
 538                 exit 1
 539         fi
 540 fi
 541 
 542 
 543 # make sure we can stash our data somewhere private
 544 if [ ! -d $SAVEDIR ]; then
 545         $MKDIR -p $SAVEDIR
 546 fi
 547 # prime the cache
 548 $STMSBOOTUTIL -i
 549 
 550 
 551 if [ "$cmd" = "enable" -o "$cmd" = "disable" -o "$cmd" = "update" ]; then
 552         #
 553         # The bootup script doesn't work on cache-only-clients as the script
 554         # is executed before the plumbing for cachefs mounting of root is done.
 555         #
 556         if $MOUNT -v | $EGREP -s " on / type (nfs|cachefs) "; then
 557                 gettext "This command option is not supported on systems with an nfs or cachefs mounted root filesystem.\n" 1>&2
 558                 exit 1
 559         fi
 560 
 561         # if the user has left the system with the mpxio-upgrade service
 562         # in a temporarily disabled state (ie, service is armed for the next
 563         # reboot), then let them know. We need to ensure that the system is
 564         # is in a sane state before allowing any further invocations, so 
 565         # try to get the system admin to do so
 566 
 567         ISARMED=`$SVCS -l $STMSINSTANCE|$GREP "enabled.*false.*temporary"`
 568         if [ ! $? ]; then
 569                 echo ""
 570                 gettext "You need to reboot the system in order to complete\n"
 571                 gettext "the previous invocation of stmsboot.\n"
 572                 echo ""
 573                 gettext "Do you wish to reboot the system now? (y/n, default y) "
 574                 read response
 575 
 576                 if [ -z "$response" -o "x$response" = "Y" -o \
 577                     "$response" = "y" ]; then
 578                         $REBOOT
 579                 else
 580                         echo ""
 581                         gettext "Please reboot this system before continuing\n"
 582                         echo ""
 583                         exit 1
 584                 fi
 585         fi
 586 
 587         #
 588         # keep a copy of the last saved files, useful for manual
 589         # recovery in case of a problem.
 590         #
 591         for d in $DRVLIST; do
 592                 DRVCONF=$d.conf
 593                 KDRVCONF=/kernel/drv/$d.conf
 594                 TMPDRVCONF=/var/run/tmp.$d.conf.$$
 595                 TMPDRVCONF_MPXIO_ENTRY=/var/run/tmp.$d.conf.mpxioentry.$$;
 596                 if [ "$MACH" = "sparc" ]; then
 597                         backup_lastsaved $KDRVCONF $VFSTAB
 598                 else
 599                         backup_lastsaved $KDRVCONF $VFSTAB /boot/solaris/$BOOTENV_FILE
 600                 fi
 601         done
 602 fi
 603 
 604 if [ "$cmd" = "enable" -o "$cmd" = "disable" ]; then
 605 
 606         msgneeded=`echo "$DRVLIST" |$GREP " "`
 607         if [ -n "$msgneeded" ]; then
 608                 emit_driver_warning_msg
 609         fi
 610         for d in $DRVLIST; do
 611                 configure_mpxio $cmd $d
 612         done
 613 
 614         if [ $reboot_needed -ne 0 ]; then
 615                 # Need to update bootpath on x86 if our boot device is
 616                 # now accessed through mpxio.
 617                 # Only update bootpath before reboot when mpxio is enabled
 618                 # If mpxio is currently disabled, we will update bootpath
 619                 # on reboot in the mpxio-upgrade service
 620                 
 621                 if [ "$cmd" = "disable" ]; then
 622                         if [ "$MACH" = "i386" ]; then
 623                                 get_newbootpath_for_stmsdev
 624                                 if [ $? -ne 0 ]; then
 625                                         $RM -f $TMPDRVCONF > /dev/null 2>&1
 626                                         gettext "failed to update bootpath.\n" 1>&2
 627                                         gettext "No changes were made to your STMS configuration.\n" 1>&2
 628                                         return 1
 629                                 fi
 630                         fi
 631                         # If we're not using ZFS root then we need
 632                         # to keep track of what / maps to in case
 633                         # it's an active-active device and we boot from
 634                         # the other path
 635                         HASZFSROOT=`$DF -g / |$GREP zfs`
 636                         if [ -z "$HASZFSROOT" ]; then
 637                                 ROOTSCSIVHCI=`$DF /|$AWK -F":" '{print $1}' | \
 638                                         $AWK -F"(" '{print $2}'| $SED -e"s,),,"`
 639                                 TMPROOTDEV=`$LS -l $ROOTSCSIVHCI |$AWK -F">" '{print $2}' | \
 640                                         $SED -e"s, ../../devices,,"`
 641                                 $STMSBOOTUTIL -q $TMPROOTDEV > $BOOTDEVICES
 642                         fi
 643                 fi
 644                 update_sysfiles
 645         else
 646                 echo "STMS is already ${cmd}d. No changes or reboots needed"
 647         fi
 648 
 649 
 650 elif [ "$cmd" = "update" ]; then
 651         if [ "$MACH" = "i386" ]; then
 652         # In this case we always change the bootpath to phci-based
 653         # path first. bootpath will later be modified in mpxio-upgrade
 654         # to the vhci-based path if mpxio is enabled on root.
 655                 get_newbootpath_for_stmsdev
 656                 if [ $? -ne 0 ]; then
 657                         gettext "failed to update bootpath.\n" 1>&2
 658                         return 1
 659                 fi
 660         fi
 661         update_sysfiles
 662 
 663 elif [ "$cmd" = "list" ]; then
 664                 $STMSBOOTUTIL $GUID -l $controller
 665 else
 666                 $STMSBOOTUTIL $GUID -L
 667 fi
 668 
 669 exit $?