xref: /illumos-gate/usr/src/cmd/stmsboot/stmsboot.sh (revision bd93c05dbd9b8f1e8d2edf48c777bc881f927608)
1a0261a43SJames C. McPherson#!/sbin/sh -p
27c478bd9Sstevel@tonic-gate#
37c478bd9Sstevel@tonic-gate# CDDL HEADER START
47c478bd9Sstevel@tonic-gate#
57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
66deb031bSsjelinek# Common Development and Distribution License (the "License").
76deb031bSsjelinek# You may not use this file except in compliance with the License.
87c478bd9Sstevel@tonic-gate#
97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate# and limitations under the License.
137c478bd9Sstevel@tonic-gate#
147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate#
207c478bd9Sstevel@tonic-gate# CDDL HEADER END
217c478bd9Sstevel@tonic-gate#
227c478bd9Sstevel@tonic-gate#
237fc66be0Sjianfei wang - Sun Microsystems - Beijing China# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
24*bd93c05dSAlexander Eremin# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
257c478bd9Sstevel@tonic-gate#
26815dd917Sjmcp#
277c478bd9Sstevel@tonic-gatePATH=/usr/bin:/usr/sbin:$PATH; export PATH
287c478bd9Sstevel@tonic-gateSTMSBOOTUTIL=/lib/mpxio/stmsboot_util
297c478bd9Sstevel@tonic-gateSTMSMETHODSCRIPT=/lib/svc/method/mpxio-upgrade
3060fffc19Sjw149990KDRVCONF=
3160fffc19Sjw149990DRVCONF=
3260fffc19Sjw149990TMPDRVCONF=
3360fffc19Sjw149990TMPDRVCONF_MPXIO_ENTRY=
34cfc4930cSYong-Feng DuTMPDRVCONF_SATA_ENTRY=
3560fffc19Sjw149990DRVLIST=
3660fffc19Sjw149990GUID=
377c478bd9Sstevel@tonic-gateVFSTAB=/etc/vfstab
387c478bd9Sstevel@tonic-gateSAVEDIR=/etc/mpxio
39789c9c8fSJames C. McPhersonBOOTDEVICES=$SAVEDIR/boot-devices
407c478bd9Sstevel@tonic-gateRECOVERFILE=$SAVEDIR/recover_instructions
417c478bd9Sstevel@tonic-gateSVCCFG_RECOVERY=$SAVEDIR/svccfg_recover
424c06356bSdh142964SUPPORTED_DRIVERS="fp|mpt|mpt_sas|pmcs"
4360fffc19Sjw149990USAGE=`gettext "Usage: stmsboot [-D $SUPPORTED_DRIVERS] -e | -d | -u | -L | -l controller_number"`
44aca6e9ccSramatTEXTDOMAIN=SUNW_OST_OSCMD
45aca6e9ccSramatexport TEXTDOMAIN
46a0261a43SJames C. McPhersonSTMSINSTANCE=svc:system/device/mpxio-upgrade:default
47c9d8e919Sjianfei wang - Sun Microsystems - Beijing ChinaFASTBOOTINSTANCE=svc:system/boot-config:default
4860fffc19Sjw149990STMSBOOT=/usr/sbin/stmsboot
4960fffc19Sjw149990BOOTADM=/sbin/bootadm
5060fffc19Sjw149990MOUNT=/usr/sbin/mount
51a0261a43SJames C. McPhersonEEPROM=/usr/sbin/eeprom
5260fffc19Sjw149990EGREP=/usr/bin/egrep
5360fffc19Sjw149990GREP=/usr/bin/grep
5460fffc19Sjw149990AWK=/usr/bin/awk
55a0261a43SJames C. McPhersonCP=/usr/bin/cp
56789c9c8fSJames C. McPhersonDF=/usr/bin/df
57a0261a43SJames C. McPhersonLS=/usr/bin/ls
58a0261a43SJames C. McPhersonMV=/usr/bin/mv
59a0261a43SJames C. McPhersonRM=/usr/bin/rm
6060fffc19Sjw149990SORT=/usr/bin/sort
6160fffc19Sjw149990UNIQ=/usr/bin/uniq
6260fffc19Sjw149990EXPR=/usr/bin/expr
63a0261a43SJames C. McPhersonMKDIR=/usr/bin/mkdir
64a0261a43SJames C. McPhersonREBOOT=/usr/sbin/reboot
65815dd917SjmcpSED=/usr/bin/sed
66815dd917SjmcpSVCPROP=/usr/bin/svcprop
67815dd917SjmcpSVCCFG=/usr/sbin/svccfg
68815dd917SjmcpSVCS=/usr/bin/svcs
69815dd917SjmcpSVCADM=/usr/sbin/svcadm
707c478bd9Sstevel@tonic-gate
71a0261a43SJames C. McPhersonNOW=`/usr/bin/date +%G%m%d_%H%M`
725a4c37c9Sqh201292MACH=`/usr/bin/uname -p`
73a0261a43SJames C. McPhersonBOOTENV_FILE=bootenv.rc
7460fffc19Sjw149990reboot_needed=0
75a0261a43SJames C. McPhersonnew_bootpath=""
76a0261a43SJames C. McPhersonCLIENT_TYPE_PHCI=""
77a0261a43SJames C. McPhersonCLIENT_TYPE_VHCI="/scsi_vhci"
7860fffc19Sjw149990
797c478bd9Sstevel@tonic-gate#
8060fffc19Sjw149990# Copy all entries (including comments) from source driver.conf
8160fffc19Sjw149990# to destination driver.conf except those entries which contain
8260fffc19Sjw149990# the mpxio-disable property.
837c478bd9Sstevel@tonic-gate# Take into consideration entries that spawn more than one line.
847c478bd9Sstevel@tonic-gate#
857c478bd9Sstevel@tonic-gate# $1	source driver.conf file
867c478bd9Sstevel@tonic-gate# $2	destination driver.conf file
877c478bd9Sstevel@tonic-gate#
887c478bd9Sstevel@tonic-gate# Returns 0 on success, non zero on failure.
897c478bd9Sstevel@tonic-gate#
907c478bd9Sstevel@tonic-gatedelete_mpxio_disable_entries()
917c478bd9Sstevel@tonic-gate{
92a0261a43SJames C. McPherson	# be careful here, we've got embedded \t characters
93a0261a43SJames C. McPherson	# in sed's pattern space.
94a0261a43SJames C. McPherson	$SED '
957c478bd9Sstevel@tonic-gate		/^[ 	]*#/{ p
967c478bd9Sstevel@tonic-gate			      d
977c478bd9Sstevel@tonic-gate			    }
987c478bd9Sstevel@tonic-gate		s/[ 	]*$//
997c478bd9Sstevel@tonic-gate		/^$/{ p
1007c478bd9Sstevel@tonic-gate		      d
1017c478bd9Sstevel@tonic-gate		    }
1025a4c37c9Sqh201292		/mpxio-disable[ 	]*=.*;$/{ w '$3'
1035a4c37c9Sqh201292						  d
1045a4c37c9Sqh201292						}
105cfc4930cSYong-Feng Du		/disable-sata-mpxio[ 	]*=.*;$/{ w '$4'
106cfc4930cSYong-Feng Du						  d
107cfc4930cSYong-Feng Du						}
1087c478bd9Sstevel@tonic-gate		/;$/{ p
1097c478bd9Sstevel@tonic-gate		      d
1107c478bd9Sstevel@tonic-gate		    }
1117c478bd9Sstevel@tonic-gate		:rdnext
1127c478bd9Sstevel@tonic-gate		N
1137c478bd9Sstevel@tonic-gate		s/[ 	]*$//
1147c478bd9Sstevel@tonic-gate		/[^;]$/b rdnext
1155a4c37c9Sqh201292		/mpxio-disable[ 	]*=/{ s/\n/ /g
1165a4c37c9Sqh201292					      w '$3'
1175a4c37c9Sqh201292					      d
1185a4c37c9Sqh201292					    }
1195a4c37c9Sqh201292		' $1 > $2
1207c478bd9Sstevel@tonic-gate
1217c478bd9Sstevel@tonic-gate	return $?
1227c478bd9Sstevel@tonic-gate}
1237c478bd9Sstevel@tonic-gate
1247c478bd9Sstevel@tonic-gate#
1257c478bd9Sstevel@tonic-gate# backup the last saved copy of the specified files.
1267c478bd9Sstevel@tonic-gate# $*	files to backup
1277c478bd9Sstevel@tonic-gate#
1287c478bd9Sstevel@tonic-gatebackup_lastsaved()
1297c478bd9Sstevel@tonic-gate{
1307c478bd9Sstevel@tonic-gate	for file in $*
1317c478bd9Sstevel@tonic-gate	do
132a0261a43SJames C. McPherson		newfile=`basename $file`
133a0261a43SJames C. McPherson		$CP $file $SAVEDIR/$newfile.$cmd.$NOW
1347c478bd9Sstevel@tonic-gate	done
1357c478bd9Sstevel@tonic-gate}
1367c478bd9Sstevel@tonic-gate
1377c478bd9Sstevel@tonic-gate#
1387c478bd9Sstevel@tonic-gate# build recover instructions
1397c478bd9Sstevel@tonic-gate#
1407c478bd9Sstevel@tonic-gate# $1	1 to include boot script in the instructions
1417c478bd9Sstevel@tonic-gate#	0 otherwise
1427c478bd9Sstevel@tonic-gate#
1437c478bd9Sstevel@tonic-gatebuild_recover()
1447c478bd9Sstevel@tonic-gate{
1457c478bd9Sstevel@tonic-gate	gettext "Instructions to recover your previous STMS configuration (if in case the system does not boot):\n\n" > $RECOVERFILE
1467c478bd9Sstevel@tonic-gate	echo "\tboot net \c"  >> $RECOVERFILE
1477c478bd9Sstevel@tonic-gate	gettext "(or from a cd/dvd/another disk)\n" >> $RECOVERFILE
1487c478bd9Sstevel@tonic-gate	echo "\tfsck <your-root-device>" >> $RECOVERFILE
1497c478bd9Sstevel@tonic-gate	echo "\tmount <your-root-device> /mnt" >> $RECOVERFILE
1507c478bd9Sstevel@tonic-gate
151fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	if [ "$cmd" = "update" ]; then
1527c478bd9Sstevel@tonic-gate		gettext "\tUndo the modifications you made to STMS configuration.\n\tFor example undo any changes you made to " >> $RECOVERFILE
15360fffc19Sjw149990		echo "/mnt$KDRVCONF." >> $RECOVERFILE
1547c478bd9Sstevel@tonic-gate	else
155a0261a43SJames C. McPherson		echo "\tcp /mnt${SAVEDIR}/$DRVCONF.$cmd.$NOW /mnt$KDRVCONF" >> $RECOVERFILE
1567c478bd9Sstevel@tonic-gate	fi
1577c478bd9Sstevel@tonic-gate
158815dd917Sjmcp	if [ $1 -eq 1 ]; then
159a0261a43SJames C. McPherson		echo "\tcp /mnt${SAVEDIR}/vfstab.$cmd.$NOW /mnt$VFSTAB" >> $RECOVERFILE
1607c478bd9Sstevel@tonic-gate
1617c478bd9Sstevel@tonic-gate		echo "repository /mnt/etc/svc/repository.db" > $SVCCFG_RECOVERY
1627c478bd9Sstevel@tonic-gate		echo "select $STMSINSTANCE" >> $SVCCFG_RECOVERY
1637c478bd9Sstevel@tonic-gate		echo "setprop general/enabled=false" >> $SVCCFG_RECOVERY
1647c478bd9Sstevel@tonic-gate		echo "exit" >> $SVCCFG_RECOVERY
1657c478bd9Sstevel@tonic-gate
166815dd917Sjmcp		echo "\t$SVCCFG -f /mnt$SVCCFG_RECOVERY" >> $RECOVERFILE
1675a4c37c9Sqh201292
168fa30e7bdSjianfei wang - Sun Microsystems - Beijing China		if [ -n "$new_bootpath" -a "$MACH" = "i386" ]; then
169a0261a43SJames C. McPherson			echo "\tcp /mnt${SAVEDIR}/bootenv.rc.$cmd.$NOW /mnt/boot/solaris/$BOOTENV_FILE" >> $RECOVERFILE
1705a4c37c9Sqh201292		fi
1717c478bd9Sstevel@tonic-gate	fi
1727c478bd9Sstevel@tonic-gate
17360fffc19Sjw149990	rootdisk=`$MOUNT | $GREP "/ on " | cut -f 3 -d " "`
1747c478bd9Sstevel@tonic-gate	echo "\tumount /mnt\n\treboot\n\n${rootdisk} \c" >> $RECOVERFILE
1757c478bd9Sstevel@tonic-gate	gettext "was your root device,\nbut it could be named differently after you boot net.\n" >> $RECOVERFILE
1767c478bd9Sstevel@tonic-gate}
1777c478bd9Sstevel@tonic-gate
178a0261a43SJames C. McPherson
1797c478bd9Sstevel@tonic-gate#
1807c478bd9Sstevel@tonic-gate# Arrange for /etc/vfstab and dump configuration to be updated
1817c478bd9Sstevel@tonic-gate# during the next reboot. If the cmd is "enable" or "disable", copy
18260fffc19Sjw149990# $TMPDRVCONF to $KDRVCONF.
1837c478bd9Sstevel@tonic-gate#
1847c478bd9Sstevel@tonic-gate# Returns 0 on success, 1 on failure.
1857c478bd9Sstevel@tonic-gate#
1867c478bd9Sstevel@tonic-gateupdate_sysfiles()
1877c478bd9Sstevel@tonic-gate{
18860fffc19Sjw149990
189a0261a43SJames C. McPherson	gettext "WARNING: This operation will require a reboot.\n"
190a0261a43SJames C. McPherson	gettext "Do you want to continue ? [y/n] (default: y) "
1917c478bd9Sstevel@tonic-gate	read response
1927c478bd9Sstevel@tonic-gate
193fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	if [ -n "$response" -a "$response" != "y" -a \
194fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	    "$response" != "Y" ]; then
19560fffc19Sjw149990		for d in $DRVLIST; do
19660fffc19Sjw149990			TMPDRVCONF=/var/run/tmp.$d.conf.$$
197a0261a43SJames C. McPherson			$RM -f $TMPDRVCONF > /dev/null 2>&1
19860fffc19Sjw149990		done;
19960fffc19Sjw149990		return 0;
2007c478bd9Sstevel@tonic-gate	fi
2017c478bd9Sstevel@tonic-gate
202815dd917Sjmcp	# set need_bootscript to the number of drivers that
203815dd917Sjmcp	# we support.
204815dd917Sjmcp	need_bootscript=`echo $SUPPORTED_DRIVERS|$AWK -F"|" '{print NF}'`
20560fffc19Sjw149990
206fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	if [ "$cmd" = "enable" -o "$cmd" = "disable" ]; then
20760fffc19Sjw149990
20860fffc19Sjw149990		for d in $DRVLIST; do
20960fffc19Sjw149990			DRVCONF=$d.conf
21060fffc19Sjw149990			KDRVCONF=/kernel/drv/$d.conf
21160fffc19Sjw149990			TMPDRVCONF=/var/run/tmp.$d.conf.$$
21260fffc19Sjw149990
213a0261a43SJames C. McPherson			$CP $KDRVCONF $SAVEDIR/`basename $KDRVCONF`.$cmd.$NOW
214815dd917Sjmcp			if [ -f $TMPDRVCONF ]; then
215a0261a43SJames C. McPherson				$CP $TMPDRVCONF $KDRVCONF
216a0261a43SJames C. McPherson				$RM -f $TMPDRVCONF
217815dd917Sjmcp			else
218815dd917Sjmcp				# if $TMPDRVCONF doesn't exist, then we
219815dd917Sjmcp				# haven't made any changes to it
220815dd917Sjmcp				continue;
221815dd917Sjmcp			fi
2227c478bd9Sstevel@tonic-gate
2237c478bd9Sstevel@tonic-gate			#
2247c478bd9Sstevel@tonic-gate			# there is no need to update the system files in the following
2257c478bd9Sstevel@tonic-gate			# cases:
2267c478bd9Sstevel@tonic-gate			# - we are enabling mpxio and the system has no configured
2277c478bd9Sstevel@tonic-gate			#   disks accessible by phci paths.
2287c478bd9Sstevel@tonic-gate			# - we are disabling mpxio and the system has no configured
2297c478bd9Sstevel@tonic-gate			#   disks accessible by vhci paths.
2307c478bd9Sstevel@tonic-gate			#
23160fffc19Sjw149990
232815dd917Sjmcp			# Function to setup the CLIENT_TYPE_PHCI string based on
233815dd917Sjmcp			# the list of drivers that we're operating on. The variable
234815dd917Sjmcp			# depends upon the pathname of the parent node in the
235815dd917Sjmcp			# device tree, which can be different on x86/x64 and sparc.
236815dd917Sjmcp
237a0261a43SJames C. McPherson			CLIENT_TYPE_PHCI=`$STMSBOOTUTIL -D $d -N`;
238815dd917Sjmcp
239fa30e7bdSjianfei wang - Sun Microsystems - Beijing China			if [ -z "$CLIENT_TYPE_PHCI" ]; then
24060fffc19Sjw149990				continue;
24160fffc19Sjw149990			fi
24260fffc19Sjw149990
243fa30e7bdSjianfei wang - Sun Microsystems - Beijing China			if [ "$cmd" = "enable" ]; then
244a0261a43SJames C. McPherson				$LS -l /dev/dsk/*s2 2> /dev/null | \
24560fffc19Sjw149990				    $EGREP -s "$CLIENT_TYPE_PHCI"
2467c478bd9Sstevel@tonic-gate			else
247a0261a43SJames C. McPherson				$LS -l /dev/dsk/*s2 2> /dev/null | \
24860fffc19Sjw149990				    $EGREP -s "$CLIENT_TYPE_VHCI"
2497c478bd9Sstevel@tonic-gate			fi
2507c478bd9Sstevel@tonic-gate
2517c478bd9Sstevel@tonic-gate			if [ $? -ne 0 ]; then
252815dd917Sjmcp				need_bootscript=`$EXPR $need_bootscript - 1`
25360fffc19Sjw149990			fi
25460fffc19Sjw149990		done
25560fffc19Sjw149990	fi
25660fffc19Sjw149990
257815dd917Sjmcp	if [ $need_bootscript -gt 0 ]; then
258815dd917Sjmcp		need_bootscript=1
259fa30e7bdSjianfei wang - Sun Microsystems - Beijing China		if [  -n "$new_bootpath" -a "$MACH" = "i386" ]; then
2605a4c37c9Sqh201292			#only update bootpath for x86.
261a0261a43SJames C. McPherson			$CP /boot/solaris/$BOOTENV_FILE $SAVEDIR/$BOOTENV_FILE.$cmd.$NOW
262a0261a43SJames C. McPherson			$EEPROM bootpath="$new_bootpath"
2635a4c37c9Sqh201292		fi
264c9d8e919Sjianfei wang - Sun Microsystems - Beijing China
265c9d8e919Sjianfei wang - Sun Microsystems - Beijing China		if [ "$MACH" = "i386" ]; then
266c9d8e919Sjianfei wang - Sun Microsystems - Beijing China			# Disable Fast Reboot temporarily for the next reboot only.
267c9d8e919Sjianfei wang - Sun Microsystems - Beijing China			HASZFSROOT=`$DF -g / |$GREP zfs`
268c9d8e919Sjianfei wang - Sun Microsystems - Beijing China			if [ -n "$HASZFSROOT" ]; then
269c9d8e919Sjianfei wang - Sun Microsystems - Beijing China				$SVCCFG -s $FASTBOOTINSTANCE addpg config_ovr application P > /dev/null 2>&1
270c9d8e919Sjianfei wang - Sun Microsystems - Beijing China				$SVCCFG -s $FASTBOOTINSTANCE \
271c9d8e919Sjianfei wang - Sun Microsystems - Beijing China				    setprop config_ovr/fastreboot_default=boolean:\"false\"
272c9d8e919Sjianfei wang - Sun Microsystems - Beijing China				$SVCCFG -s $FASTBOOTINSTANCE \
273c9d8e919Sjianfei wang - Sun Microsystems - Beijing China				    setprop config_ovr/fastreboot_onpanic=boolean:\"false\"
274c9d8e919Sjianfei wang - Sun Microsystems - Beijing China				$SVCADM refresh $FASTBOOTINSTANCE
275c9d8e919Sjianfei wang - Sun Microsystems - Beijing China			fi
276c9d8e919Sjianfei wang - Sun Microsystems - Beijing China		fi
277c9d8e919Sjianfei wang - Sun Microsystems - Beijing China
278a0261a43SJames C. McPherson		# Enable the mpxio-upgrade service for the reboot
279815dd917Sjmcp		$SVCADM disable -t $STMSINSTANCE
280a0261a43SJames C. McPherson		$SVCCFG -s $STMSINSTANCE "setprop general/enabled=true"
281815dd917Sjmcp	else
282815dd917Sjmcp		need_bootscript=0
2837c478bd9Sstevel@tonic-gate	fi
2847c478bd9Sstevel@tonic-gate
2857c478bd9Sstevel@tonic-gate	build_recover $need_bootscript
2867c478bd9Sstevel@tonic-gate
287fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	if [ "$MACH" = "i386" ]; then
28860fffc19Sjw149990		$BOOTADM update-archive
28960fffc19Sjw149990	fi
29060fffc19Sjw149990
2917c478bd9Sstevel@tonic-gate	gettext "The changes will come into effect after rebooting the system.\nReboot the system now ? [y/n] (default: y) "
2927c478bd9Sstevel@tonic-gate	read response
2937c478bd9Sstevel@tonic-gate
294fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	if [ -z "$response" -o "$response" = "y" -o \
295fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	    "$response" = "Y" ]; then
296a0261a43SJames C. McPherson		$REBOOT
2977c478bd9Sstevel@tonic-gate	fi
2987c478bd9Sstevel@tonic-gate
2997c478bd9Sstevel@tonic-gate	return 0
3007c478bd9Sstevel@tonic-gate}
3017c478bd9Sstevel@tonic-gate
302a0261a43SJames C. McPherson
3037c478bd9Sstevel@tonic-gate#
3047c478bd9Sstevel@tonic-gate# Enable or disable mpxio as specified by the cmd.
3057c478bd9Sstevel@tonic-gate# Returns 0 on success, 1 on failure.
3067c478bd9Sstevel@tonic-gate#
30760fffc19Sjw149990# Args: $cmd = {enable | disable}
3084c06356bSdh142964#	$d = {fp | mpt | mpt_sas | pmcs}
30960fffc19Sjw149990#
31060fffc19Sjw149990# the global variable $DRVLIST is used
31160fffc19Sjw149990#
3127c478bd9Sstevel@tonic-gateconfigure_mpxio()
3137c478bd9Sstevel@tonic-gate{
314a0261a43SJames C. McPherson	# be careful here, we've got embedded \t characters
315a0261a43SJames C. McPherson	# in sed's pattern space.
3165a4c37c9Sqh201292	mpxiodisableno='mpxio-disable[ 	]*=[ 	]*"no"[ 	]*;'
3175a4c37c9Sqh201292	mpxiodisableyes='mpxio-disable[ 	]*=[ 	]*"yes"[ 	]*;'
318cfc4930cSYong-Feng Du	satadisableno='disable-sata-mpxio[ 	]*=[ 	]*"no"[ 	]*;'
319cfc4930cSYong-Feng Du	satadisableyes='disable-sata-mpxio[ 	]*=[ 	]*"yes"[ 	]*;'
3205a4c37c9Sqh201292
321fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	if [ "$cmd" = "enable" ]; then
3225a4c37c9Sqh201292		mpxiodisable_cur_entry=$mpxiodisableyes
323cfc4930cSYong-Feng Du		satadisable_cur_entry=$satadisableyes
3247c478bd9Sstevel@tonic-gate		propval=no
32560fffc19Sjw149990		msg=`gettext "STMS already enabled"`
3267c478bd9Sstevel@tonic-gate	else
3275a4c37c9Sqh201292		mpxiodisable_cur_entry=$mpxiodisableno
328cfc4930cSYong-Feng Du		satadisable_cur_entry=$satadisableno
3297c478bd9Sstevel@tonic-gate		propval=yes
33060fffc19Sjw149990		msg=`gettext "STMS already disabled"`
3317c478bd9Sstevel@tonic-gate	fi
3327c478bd9Sstevel@tonic-gate
33360fffc19Sjw149990	DRVCONF=$d.conf
33460fffc19Sjw149990	KDRVCONF=/kernel/drv/$d.conf
33560fffc19Sjw149990	TMPDRVCONF=/var/run/tmp.$d.conf.$$
33660fffc19Sjw149990	TMPDRVCONF_MPXIO_ENTRY=/var/run/tmp.$d.conf.mpxioentry.$$;
337cfc4930cSYong-Feng Du	TMPDRVCONF_SATA_ENTRY=/var/run/tmp.$d.conf.sataentry.$$;
33860fffc19Sjw149990
339cfc4930cSYong-Feng Du	if delete_mpxio_disable_entries $KDRVCONF $TMPDRVCONF $TMPDRVCONF_MPXIO_ENTRY $TMPDRVCONF_SATA_ENTRY; then
34060fffc19Sjw149990
34160fffc19Sjw149990		if [ -s $TMPDRVCONF_MPXIO_ENTRY ]; then
34260fffc19Sjw149990			# $DRVCONF does have mpxiodisable entries
34360fffc19Sjw149990			$EGREP -s "$mpxiodisable_cur_entry" $TMPDRVCONF_MPXIO_ENTRY
344cfc4930cSYong-Feng Du			if [ $? -eq 0 ]; then
345cfc4930cSYong-Feng Du				reboot_needed=`$EXPR $reboot_needed + 1`
346cfc4930cSYong-Feng Du			else
3475a4c37c9Sqh201292				# if all mpxiodisable entries are no/yes for
3485a4c37c9Sqh201292				# enable/disable mpxio, notify the user
349cfc4930cSYong-Feng Du				$EGREP -s "$satadisable_cur_entry" $TMPDRVCONF_SATA_ENTRY
350fa30e7bdSjianfei wang - Sun Microsystems - Beijing China				if [ $? -eq 0 -a "$d" = "mpt" ]; then
35160fffc19Sjw149990					reboot_needed=`$EXPR $reboot_needed + 1`
352cfc4930cSYong-Feng Du				else
353cfc4930cSYong-Feng Du					$RM -f $TMPDRVCONF $TMPDRVCONF_MPXIO_ENTRY $TMPDRVCONF_SATA_ENTRY > /dev/null 2>&1
354ccb7005eSYong-Feng Du					return 0;
355cfc4930cSYong-Feng Du				fi
3567c478bd9Sstevel@tonic-gate			fi
35760fffc19Sjw149990
35860fffc19Sjw149990			# If mpxiodisable entries do not exist, always continue update
3595a4c37c9Sqh201292		fi
3607c478bd9Sstevel@tonic-gate	else
361cfc4930cSYong-Feng Du		$RM -f $TMPDRVCONF $TMPDRVCONF_MPXIO_ENTRY $TMPDRVCONF_SATA_ENTRY > /dev/null 2>&1
3627c478bd9Sstevel@tonic-gate		gettext "failed to update " 1>&2
36360fffc19Sjw149990		echo "$KDRVCONF." 1>&2
3647c478bd9Sstevel@tonic-gate		gettext "No changes were made to your STMS configuration.\n" 1>&2
3657c478bd9Sstevel@tonic-gate		return 1
3667c478bd9Sstevel@tonic-gate	fi
3675a4c37c9Sqh201292
36835c62094Sjianfei wang - Sun Microsystems - Beijing China	rm $TMPDRVCONF_MPXIO_ENTRY $TMPDRVCONF_SATA_ENTRY > /dev/null 2>&1
36960fffc19Sjw149990	echo "mpxio-disable=\"${propval}\";" >> $TMPDRVCONF
370fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	if [ "$d" = "mpt" ]; then
371cfc4930cSYong-Feng Du		echo "disable-sata-mpxio=\"${propval}\";" >> $TMPDRVCONF
37235c62094Sjianfei wang - Sun Microsystems - Beijing China	fi
3735a4c37c9Sqh201292
3747c478bd9Sstevel@tonic-gate}
3757c478bd9Sstevel@tonic-gate
3767c478bd9Sstevel@tonic-gatesetcmd()
3777c478bd9Sstevel@tonic-gate{
378fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	if [ "$cmd" = "none" ]; then
3797c478bd9Sstevel@tonic-gate		cmd=$1
3807c478bd9Sstevel@tonic-gate	else
3817c478bd9Sstevel@tonic-gate		echo "$USAGE" 1>&2
3827c478bd9Sstevel@tonic-gate		exit 2
3837c478bd9Sstevel@tonic-gate	fi
3847c478bd9Sstevel@tonic-gate}
3857c478bd9Sstevel@tonic-gate
38660fffc19Sjw149990#
3875a4c37c9Sqh201292# Need to update bootpath on x86 if boot system from FC disk
3885a4c37c9Sqh201292# Only update bootpath here when mpxio is enabled
389a0261a43SJames C. McPherson# If mpxio is currently disabled, then we'll update bootpath in the
390a0261a43SJames C. McPherson# mpxio-upgrade service method on reboot.
39160fffc19Sjw149990#
39260fffc19Sjw149990
3935a4c37c9Sqh201292get_newbootpath_for_stmsdev() {
394fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	if [ "$cmd" = "enable" ]; then
3955a4c37c9Sqh201292		return 0
3965a4c37c9Sqh201292	fi
3975a4c37c9Sqh201292
398a0261a43SJames C. McPherson	cur_bootpath=`$STMSBOOTUTIL -b`
399a0261a43SJames C. McPherson	if [ $? != 0 ]; then
4005a4c37c9Sqh201292		return 1
4015a4c37c9Sqh201292	fi
4025a4c37c9Sqh201292
403a0261a43SJames C. McPherson	# Since on x64 platforms the eeprom command doesn't update the
404a0261a43SJames C. McPherson	# kernel, the file /boot/solaris/bootenv.rc and the kernel's
405a0261a43SJames C. McPherson	# bootpath variable have a good chance of differing. We do some
406a0261a43SJames C. McPherson	# extra handwaving to get the correct bootpath variable setting.
407a0261a43SJames C. McPherson
408a0261a43SJames C. McPherson	ONDISKVER=`$AWK '/bootpath/ {print $3}' /boot/solaris/bootenv.rc|\
409a0261a43SJames C. McPherson		$SED -e"s,',,g"`
410fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	if [ "$ONDISKVER" != "$cur_bootpath" ]; then
411a0261a43SJames C. McPherson		cur_bootpath="$ONDISKVER"
412a0261a43SJames C. McPherson	fi
413a0261a43SJames C. McPherson
414a0261a43SJames C. McPherson	NEWBOOTPATH=""
415a0261a43SJames C. McPherson	for path in $cur_bootpath; do
416a0261a43SJames C. McPherson		mapped=`$STMSBOOTUTIL -p $path`
417a0261a43SJames C. McPherson		if [ "$mapped" != "NOT_MAPPED" ]; then
418a0261a43SJames C. McPherson			if [ "$mapped" != "$path" ]; then
419a0261a43SJames C. McPherson				NEWBOOTPATH=`echo "$path " | \
420a0261a43SJames C. McPherson				   $SED -e"s|$path|$mapped|"`" $NEWBOOTPATH"
421a0261a43SJames C. McPherson			else
422a0261a43SJames C. McPherson				NEWBOOTPATH="$NEWBOOTPATH $path"
423a0261a43SJames C. McPherson			fi
424a0261a43SJames C. McPherson		fi
425a0261a43SJames C. McPherson	done
426a0261a43SJames C. McPherson	# now strip off leading and trailing space chars
427a0261a43SJames C. McPherson	new_bootpath=`echo $NEWBOOTPATH`
4285a4c37c9Sqh201292	return 0
42960fffc19Sjw149990}
43060fffc19Sjw149990
43160fffc19Sjw149990#
43260fffc19Sjw149990# Emit a warning message to the user that by default we
43360fffc19Sjw149990# operate on all multipath-capable controllers that are
43460fffc19Sjw149990# attached to the system, and that if they want to operate
4354c06356bSdh142964# on only a specific controller type (fp|mpt|mpt_sas|pmcs|....) then
43660fffc19Sjw149990# they need to re-invoke stmsboot with "-D $driver" in
43760fffc19Sjw149990# their argument list
43860fffc19Sjw149990#
43960fffc19Sjw149990
44060fffc19Sjw149990emit_driver_warning_msg() {
44160fffc19Sjw149990
44260fffc19Sjw149990	# for each driver that we support, grab the list
44360fffc19Sjw149990	# of controllers attached to the system.
44460fffc19Sjw149990
445815dd917Sjmcp	echo ""
44653ed03b5Sjmcp	gettext "WARNING: stmsboot operates on each supported multipath-capable controller\n"
44753ed03b5Sjmcp	gettext "         detected in a host. In your system, these controllers are\n\n"
44860fffc19Sjw149990
449815dd917Sjmcp	for WARNDRV in `echo $SUPPORTED_DRIVERS| $SED -e"s,|, ,g"`; do
450a0261a43SJames C. McPherson		$STMSBOOTUTIL -D $WARNDRV -n
45160fffc19Sjw149990	done;
45260fffc19Sjw149990
45360fffc19Sjw149990	echo ""
45453ed03b5Sjmcp	gettext "If you do NOT wish to operate on these controllers, please quit stmsboot\n"
4554c06356bSdh142964	gettext "and re-invoke with -D { fp | mpt | mpt_sas | pmcs} to specify which controllers you wish\n"
45653ed03b5Sjmcp	gettext "to modify your multipathing configuration for.\n"
45760fffc19Sjw149990
458815dd917Sjmcp	echo ""
45953ed03b5Sjmcp	gettext "Do you wish to continue? [y/n] (default: y) "
46060fffc19Sjw149990	read response
46160fffc19Sjw149990
462fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	if [ -n "$response" -a "$response" != "Y" -a \
463fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	    "$response" != "y" ]; then
46460fffc19Sjw149990		exit
46560fffc19Sjw149990	fi
46660fffc19Sjw149990}
46760fffc19Sjw149990
4687c478bd9Sstevel@tonic-gate
469a0261a43SJames C. McPherson#
470a0261a43SJames C. McPherson#
471a0261a43SJames C. McPherson# main starts here
472a0261a43SJames C. McPherson#
473a0261a43SJames C. McPherson
474a0261a43SJames C. McPhersoncmd=none
4757c478bd9Sstevel@tonic-gate# process options
47660fffc19Sjw149990while getopts D:geduLl: c
4777c478bd9Sstevel@tonic-gatedo
4787c478bd9Sstevel@tonic-gate	case $c in
4797c478bd9Sstevel@tonic-gate	e)	setcmd enable;;
4807c478bd9Sstevel@tonic-gate	d)	setcmd disable;;
4817c478bd9Sstevel@tonic-gate	u)	setcmd update;;
4827c478bd9Sstevel@tonic-gate	L)	setcmd listall;;
4837c478bd9Sstevel@tonic-gate	l)	setcmd list
4847c478bd9Sstevel@tonic-gate		controller=$OPTARG;;
48560fffc19Sjw149990	D)	DRV=$OPTARG;;
48660fffc19Sjw149990	g)	GUID="-g";;
4877c478bd9Sstevel@tonic-gate	\?)	echo "$USAGE" 1>&2
4887c478bd9Sstevel@tonic-gate		exit 2;;
4897c478bd9Sstevel@tonic-gate	esac
4907c478bd9Sstevel@tonic-gatedone
4917c478bd9Sstevel@tonic-gate
492fa30e7bdSjianfei wang - Sun Microsystems - Beijing Chinaif [ "$cmd" = "none" ]; then
4937c478bd9Sstevel@tonic-gate	echo "$USAGE" 1>&2
4947c478bd9Sstevel@tonic-gate	exit 2
4957c478bd9Sstevel@tonic-gatefi
4967c478bd9Sstevel@tonic-gate
497fa30e7bdSjianfei wang - Sun Microsystems - Beijing Chinaif [ -z "$DRV" ]; then
4984c06356bSdh142964	DRVLIST="fp mpt mpt_sas pmcs"
49960fffc19Sjw149990else
50060fffc19Sjw149990	DRVLIST=$DRV
50160fffc19Sjw149990fi
50260fffc19Sjw149990
50334c94816SjmcpUSERID=`id | $EGREP "uid=0"`
50434c94816Sjmcpif [ -z "$USERID" ]; then
5057c478bd9Sstevel@tonic-gate	gettext "You must be super-user to run this script.\n" 1>&2
5067c478bd9Sstevel@tonic-gate	exit 1
5077c478bd9Sstevel@tonic-gatefi
5087c478bd9Sstevel@tonic-gate
5097c478bd9Sstevel@tonic-gate# just a sanity check
5107c478bd9Sstevel@tonic-gateif [ ! -f $STMSBOOTUTIL -o ! -f $STMSMETHODSCRIPT ]; then
5117c478bd9Sstevel@tonic-gate	fmt=`gettext "Can't find %s and/or %s"`
5127c478bd9Sstevel@tonic-gate	printf "$fmt\n" "$STMSBOOTUTIL" "$STMSMETHODSCRIPT" 1>&2
5137c478bd9Sstevel@tonic-gate	exit 1
5147c478bd9Sstevel@tonic-gatefi
5157c478bd9Sstevel@tonic-gate
51660fffc19Sjw149990# If the old sun4u-specific SMF method is found, remove it
517815dd917Sjmcp$SVCCFG -s "platform/sun4u/mpxio-upgrade:default" < /dev/null > /dev/null 2>&1
518815dd917Sjmcpif [ $? -eq 0 ]; then
519815dd917Sjmcp	$SVCCFG delete "platform/sun4u/mpxio-upgrade:default" > /dev/null 2>&1
52060fffc19Sjw149990fi
52160fffc19Sjw149990
52260fffc19Sjw149990# now import the new service, if necessary
523815dd917Sjmcp$SVCPROP -q $STMSINSTANCE < /dev/null > /dev/null 2>&1
52460fffc19Sjw149990if [ $? -ne 0 ]; then
5259444c26fSTom Whitten	if [ -f /lib/svc/manifest/system/device/mpxio-upgrade.xml ]; then
5269444c26fSTom Whitten		$SVCCFG import /lib/svc/manifest/system/device/mpxio-upgrade.xml
52760fffc19Sjw149990		if [ $? -ne 0 ]; then
528fa30e7bdSjianfei wang - Sun Microsystems - Beijing China
52953ed03b5Sjmcp			fmt=`gettext "Unable to import the %s service"`
5307c478bd9Sstevel@tonic-gate			printf "$fmt\n" "$STMSINSTANCE" 1>&2
5317c478bd9Sstevel@tonic-gate			exit 1
53260fffc19Sjw149990		else
53360fffc19Sjw149990			fmt=`gettext "Service %s imported successfully, continuing"`
53460fffc19Sjw149990			printf "$fmt\n" "$STMSINSTANCE" 1>&2
53560fffc19Sjw149990		fi
53660fffc19Sjw149990	else
53760fffc19Sjw149990		fmt=`gettext "Service %s does not exist on this host"`
53860fffc19Sjw149990 		printf "$fmt\n" "$STMSINSTANCE" 1>&2
53960fffc19Sjw149990		exit 1
54060fffc19Sjw149990	fi
5417c478bd9Sstevel@tonic-gatefi
5427c478bd9Sstevel@tonic-gate
543a0261a43SJames C. McPherson
544a0261a43SJames C. McPherson# make sure we can stash our data somewhere private
545a0261a43SJames C. McPhersonif [ ! -d $SAVEDIR ]; then
546a0261a43SJames C. McPherson	$MKDIR -p $SAVEDIR
547a0261a43SJames C. McPhersonfi
548a0261a43SJames C. McPherson# prime the cache
549a0261a43SJames C. McPherson$STMSBOOTUTIL -i
550a0261a43SJames C. McPherson
551a0261a43SJames C. McPherson
552fa30e7bdSjianfei wang - Sun Microsystems - Beijing Chinaif [ "$cmd" = "enable" -o "$cmd" = "disable" -o "$cmd" = "update" ]; then
553*bd93c05dSAlexander Eremin	if $MOUNT -v | $EGREP -s " on / type nfs "; then
554*bd93c05dSAlexander Eremin		gettext "This command option is not supported on systems with an nfs mounted root filesystem.\n" 1>&2
5557c478bd9Sstevel@tonic-gate		exit 1
5567c478bd9Sstevel@tonic-gate	fi
5577c478bd9Sstevel@tonic-gate
558815dd917Sjmcp	# if the user has left the system with the mpxio-upgrade service
559815dd917Sjmcp	# in a temporarily disabled state (ie, service is armed for the next
560815dd917Sjmcp	# reboot), then let them know. We need to ensure that the system is
561815dd917Sjmcp	# is in a sane state before allowing any further invocations, so
562815dd917Sjmcp	# try to get the system admin to do so
563815dd917Sjmcp
564a0261a43SJames C. McPherson	ISARMED=`$SVCS -l $STMSINSTANCE|$GREP "enabled.*false.*temporary"`
565a0261a43SJames C. McPherson	if [ ! $? ]; then
566815dd917Sjmcp		echo ""
56753ed03b5Sjmcp		gettext "You need to reboot the system in order to complete\n"
56853ed03b5Sjmcp		gettext "the previous invocation of stmsboot.\n"
569815dd917Sjmcp		echo ""
57053ed03b5Sjmcp		gettext "Do you wish to reboot the system now? (y/n, default y) "
571815dd917Sjmcp		read response
572815dd917Sjmcp
573fa30e7bdSjianfei wang - Sun Microsystems - Beijing China		if [ -z "$response" -o "x$response" = "Y" -o \
574fa30e7bdSjianfei wang - Sun Microsystems - Beijing China		    "$response" = "y" ]; then
575a0261a43SJames C. McPherson			$REBOOT
576815dd917Sjmcp		else
57753ed03b5Sjmcp			echo ""
57853ed03b5Sjmcp			gettext "Please reboot this system before continuing\n"
57953ed03b5Sjmcp			echo ""
580815dd917Sjmcp			exit 1
581815dd917Sjmcp		fi
582815dd917Sjmcp	fi
583815dd917Sjmcp
5847c478bd9Sstevel@tonic-gate	#
5857c478bd9Sstevel@tonic-gate	# keep a copy of the last saved files, useful for manual
5867c478bd9Sstevel@tonic-gate	# recovery in case of a problem.
5877c478bd9Sstevel@tonic-gate	#
58860fffc19Sjw149990	for d in $DRVLIST; do
58960fffc19Sjw149990		DRVCONF=$d.conf
59060fffc19Sjw149990		KDRVCONF=/kernel/drv/$d.conf
59160fffc19Sjw149990		TMPDRVCONF=/var/run/tmp.$d.conf.$$
59260fffc19Sjw149990		TMPDRVCONF_MPXIO_ENTRY=/var/run/tmp.$d.conf.mpxioentry.$$;
593fa30e7bdSjianfei wang - Sun Microsystems - Beijing China		if [ "$MACH" = "sparc" ]; then
59460fffc19Sjw149990			backup_lastsaved $KDRVCONF $VFSTAB
5957c478bd9Sstevel@tonic-gate		else
596a0261a43SJames C. McPherson			backup_lastsaved $KDRVCONF $VFSTAB /boot/solaris/$BOOTENV_FILE
5975a4c37c9Sqh201292		fi
59860fffc19Sjw149990	done
5997c478bd9Sstevel@tonic-gatefi
6007c478bd9Sstevel@tonic-gate
601fa30e7bdSjianfei wang - Sun Microsystems - Beijing Chinaif [ "$cmd" = "enable" -o "$cmd" = "disable" ]; then
60260fffc19Sjw149990
6037fc66be0Sjianfei wang - Sun Microsystems - Beijing China	msgneeded=`echo "$DRVLIST" |$GREP " "`
60460fffc19Sjw149990	if [ -n "$msgneeded" ]; then
60560fffc19Sjw149990		emit_driver_warning_msg
60660fffc19Sjw149990	fi
60760fffc19Sjw149990	for d in $DRVLIST; do
60860fffc19Sjw149990		configure_mpxio $cmd $d
60960fffc19Sjw149990	done
61060fffc19Sjw149990
61160fffc19Sjw149990	if [ $reboot_needed -ne 0 ]; then
61260fffc19Sjw149990		# Need to update bootpath on x86 if our boot device is
61360fffc19Sjw149990		# now accessed through mpxio.
61460fffc19Sjw149990		# Only update bootpath before reboot when mpxio is enabled
61560fffc19Sjw149990		# If mpxio is currently disabled, we will update bootpath
61660fffc19Sjw149990		# on reboot in the mpxio-upgrade service
61760fffc19Sjw149990
618fa30e7bdSjianfei wang - Sun Microsystems - Beijing China		if [ "$cmd" = "disable" ]; then
619fa30e7bdSjianfei wang - Sun Microsystems - Beijing China			if [ "$MACH" = "i386" ]; then
62060fffc19Sjw149990				get_newbootpath_for_stmsdev
62160fffc19Sjw149990				if [ $? -ne 0 ]; then
622a0261a43SJames C. McPherson					$RM -f $TMPDRVCONF > /dev/null 2>&1
62360fffc19Sjw149990					gettext "failed to update bootpath.\n" 1>&2
62460fffc19Sjw149990					gettext "No changes were made to your STMS configuration.\n" 1>&2
62560fffc19Sjw149990					return 1
62660fffc19Sjw149990				fi
62760fffc19Sjw149990			fi
628789c9c8fSJames C. McPherson			# If we're not using ZFS root then we need
629789c9c8fSJames C. McPherson			# to keep track of what / maps to in case
630789c9c8fSJames C. McPherson			# it's an active-active device and we boot from
631789c9c8fSJames C. McPherson			# the other path
6327fc66be0Sjianfei wang - Sun Microsystems - Beijing China			HASZFSROOT=`$DF -g / |$GREP zfs`
6337fc66be0Sjianfei wang - Sun Microsystems - Beijing China			if [ -z "$HASZFSROOT" ]; then
634789c9c8fSJames C. McPherson				ROOTSCSIVHCI=`$DF /|$AWK -F":" '{print $1}' | \
6357fc66be0Sjianfei wang - Sun Microsystems - Beijing China					$AWK -F"(" '{print $2}'| $SED -e"s,),,"`
6367fc66be0Sjianfei wang - Sun Microsystems - Beijing China				TMPROOTDEV=`$LS -l $ROOTSCSIVHCI |$AWK -F">" '{print $2}' | \
6377fc66be0Sjianfei wang - Sun Microsystems - Beijing China					$SED -e"s, ../../devices,,"`
6387fc66be0Sjianfei wang - Sun Microsystems - Beijing China				$STMSBOOTUTIL -q $TMPROOTDEV > $BOOTDEVICES
6397fc66be0Sjianfei wang - Sun Microsystems - Beijing China			fi
640789c9c8fSJames C. McPherson		fi
64160fffc19Sjw149990		update_sysfiles
64260fffc19Sjw149990	else
64360fffc19Sjw149990		echo "STMS is already ${cmd}d. No changes or reboots needed"
64460fffc19Sjw149990	fi
64560fffc19Sjw149990
64660fffc19Sjw149990
647fa30e7bdSjianfei wang - Sun Microsystems - Beijing Chinaelif [ "$cmd" = "update" ]; then
648fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	if [ "$MACH" = "i386" ]; then
6495a4c37c9Sqh201292	# In this case we always change the bootpath to phci-based
6505a4c37c9Sqh201292	# path first. bootpath will later be modified in mpxio-upgrade
6515a4c37c9Sqh201292	# to the vhci-based path if mpxio is enabled on root.
6525a4c37c9Sqh201292		get_newbootpath_for_stmsdev
6535a4c37c9Sqh201292		if [ $? -ne 0 ]; then
6545a4c37c9Sqh201292			gettext "failed to update bootpath.\n" 1>&2
6555a4c37c9Sqh201292			return 1
6565a4c37c9Sqh201292		fi
6575a4c37c9Sqh201292	fi
6587c478bd9Sstevel@tonic-gate	update_sysfiles
65960fffc19Sjw149990
660fa30e7bdSjianfei wang - Sun Microsystems - Beijing Chinaelif [ "$cmd" = "list" ]; then
66160fffc19Sjw149990		$STMSBOOTUTIL $GUID -l $controller
6627c478bd9Sstevel@tonic-gateelse
66360fffc19Sjw149990		$STMSBOOTUTIL $GUID -L
6647c478bd9Sstevel@tonic-gatefi
6657c478bd9Sstevel@tonic-gate
6667c478bd9Sstevel@tonic-gateexit $?
667