17c478bd9Sstevel@tonic-gate#!/sbin/sh 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# 235a4c37c9Sqh201292# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate# Use is subject to license terms. 257c478bd9Sstevel@tonic-gate# 267c478bd9Sstevel@tonic-gate#ident "%Z%%M% %I% %E% SMI" 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gatePATH=/usr/bin:/usr/sbin:$PATH; export PATH 297c478bd9Sstevel@tonic-gateSTMSBOOTUTIL=/lib/mpxio/stmsboot_util 307c478bd9Sstevel@tonic-gateSTMSMETHODSCRIPT=/lib/svc/method/mpxio-upgrade 31*60fffc19Sjw149990KDRVCONF= 32*60fffc19Sjw149990DRVCONF= 33*60fffc19Sjw149990TMPDRVCONF= 34*60fffc19Sjw149990TMPDRVCONF_MPXIO_ENTRY= 35*60fffc19Sjw149990DRVLIST= 36*60fffc19Sjw149990GUID= 377c478bd9Sstevel@tonic-gateVFSTAB=/etc/vfstab 387c478bd9Sstevel@tonic-gateSAVEDIR=/etc/mpxio 397c478bd9Sstevel@tonic-gateRECOVERFILE=$SAVEDIR/recover_instructions 407c478bd9Sstevel@tonic-gateSVCCFG_RECOVERY=$SAVEDIR/svccfg_recover 41*60fffc19Sjw149990SUPPORTED_DRIVERS="fp|mpt" 42*60fffc19Sjw149990USAGE=`gettext "Usage: stmsboot [-D $SUPPORTED_DRIVERS] -e | -d | -u | -L | -l controller_number"` 43aca6e9ccSramatTEXTDOMAIN=SUNW_OST_OSCMD 44aca6e9ccSramatexport TEXTDOMAIN 455a4c37c9Sqh201292STMSINSTANCE=system/device/mpxio-upgrade:default 46*60fffc19Sjw149990STMSBOOT=/usr/sbin/stmsboot 47*60fffc19Sjw149990BOOTADM=/sbin/bootadm 48*60fffc19Sjw149990MOUNT=/usr/sbin/mount 49*60fffc19Sjw149990EGREP=/usr/bin/egrep 50*60fffc19Sjw149990GREP=/usr/bin/grep 51*60fffc19Sjw149990AWK=/usr/bin/awk 52*60fffc19Sjw149990SORT=/usr/bin/sort 53*60fffc19Sjw149990UNIQ=/usr/bin/uniq 54*60fffc19Sjw149990EXPR=/usr/bin/expr 557c478bd9Sstevel@tonic-gate 565a4c37c9Sqh201292MACH=`/usr/bin/uname -p` 575a4c37c9Sqh201292BOOTENV_FILE=/boot/solaris/bootenv.rc 58*60fffc19Sjw149990 59*60fffc19Sjw149990CLIENT_TYPE_VHCI="/scsi_vhci.*/ssd@|/scsi_vhci.*/disk@" 60*60fffc19Sjw149990# The phci client type egrep string will change based on the 61*60fffc19Sjw149990# drivers which we are operating on, and the cpu architecture 62*60fffc19Sjw149990# and we call stmsboot_util -n -D $drv to get that string 63*60fffc19Sjw149990CLIENT_TYPE_PHCI= 64*60fffc19Sjw149990reboot_needed=0 65*60fffc19Sjw149990 667c478bd9Sstevel@tonic-gate# 67*60fffc19Sjw149990# Copy all entries (including comments) from source driver.conf 68*60fffc19Sjw149990# to destination driver.conf except those entries which contain 69*60fffc19Sjw149990# the mpxio-disable property. 707c478bd9Sstevel@tonic-gate# Take into consideration entries that spawn more than one line. 717c478bd9Sstevel@tonic-gate# 727c478bd9Sstevel@tonic-gate# $1 source driver.conf file 737c478bd9Sstevel@tonic-gate# $2 destination driver.conf file 747c478bd9Sstevel@tonic-gate# 757c478bd9Sstevel@tonic-gate# Returns 0 on success, non zero on failure. 767c478bd9Sstevel@tonic-gate# 777c478bd9Sstevel@tonic-gatedelete_mpxio_disable_entries() 787c478bd9Sstevel@tonic-gate{ 797c478bd9Sstevel@tonic-gate sed ' 807c478bd9Sstevel@tonic-gate /^[ ]*#/{ p 817c478bd9Sstevel@tonic-gate d 827c478bd9Sstevel@tonic-gate } 837c478bd9Sstevel@tonic-gate s/[ ]*$// 847c478bd9Sstevel@tonic-gate /^$/{ p 857c478bd9Sstevel@tonic-gate d 867c478bd9Sstevel@tonic-gate } 875a4c37c9Sqh201292 /mpxio-disable[ ]*=.*;$/{ w '$3' 885a4c37c9Sqh201292 d 895a4c37c9Sqh201292 } 907c478bd9Sstevel@tonic-gate /;$/{ p 917c478bd9Sstevel@tonic-gate d 927c478bd9Sstevel@tonic-gate } 937c478bd9Sstevel@tonic-gate :rdnext 947c478bd9Sstevel@tonic-gate N 957c478bd9Sstevel@tonic-gate s/[ ]*$// 967c478bd9Sstevel@tonic-gate /[^;]$/b rdnext 975a4c37c9Sqh201292 /mpxio-disable[ ]*=/{ s/\n/ /g 985a4c37c9Sqh201292 w '$3' 995a4c37c9Sqh201292 d 1005a4c37c9Sqh201292 } 1015a4c37c9Sqh201292 ' $1 > $2 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate return $? 1047c478bd9Sstevel@tonic-gate} 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate# 1077c478bd9Sstevel@tonic-gate# backup the last saved copy of the specified files. 1087c478bd9Sstevel@tonic-gate# $* files to backup 1097c478bd9Sstevel@tonic-gate# 1107c478bd9Sstevel@tonic-gatebackup_lastsaved() 1117c478bd9Sstevel@tonic-gate{ 1127c478bd9Sstevel@tonic-gate for file in $* 1137c478bd9Sstevel@tonic-gate do 1147c478bd9Sstevel@tonic-gate file=`basename $file` 1157c478bd9Sstevel@tonic-gate if [ -f $SAVEDIR/$file ]; then 1167c478bd9Sstevel@tonic-gate mv $SAVEDIR/$file $SAVEDIR/${file}.old 1177c478bd9Sstevel@tonic-gate fi 1187c478bd9Sstevel@tonic-gate done 1197c478bd9Sstevel@tonic-gate} 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate# 1227c478bd9Sstevel@tonic-gate# build recover instructions 1237c478bd9Sstevel@tonic-gate# 1247c478bd9Sstevel@tonic-gate# $1 1 to include boot script in the instructions 1257c478bd9Sstevel@tonic-gate# 0 otherwise 1267c478bd9Sstevel@tonic-gate# 1277c478bd9Sstevel@tonic-gatebuild_recover() 1287c478bd9Sstevel@tonic-gate{ 1297c478bd9Sstevel@tonic-gate gettext "Instructions to recover your previous STMS configuration (if in case the system does not boot):\n\n" > $RECOVERFILE 1307c478bd9Sstevel@tonic-gate echo "\tboot net \c" >> $RECOVERFILE 1317c478bd9Sstevel@tonic-gate gettext "(or from a cd/dvd/another disk)\n" >> $RECOVERFILE 1327c478bd9Sstevel@tonic-gate echo "\tfsck <your-root-device>" >> $RECOVERFILE 1337c478bd9Sstevel@tonic-gate echo "\tmount <your-root-device> /mnt" >> $RECOVERFILE 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate if [ "x$cmd" = xupdate ]; then 1367c478bd9Sstevel@tonic-gate gettext "\tUndo the modifications you made to STMS configuration.\n\tFor example undo any changes you made to " >> $RECOVERFILE 137*60fffc19Sjw149990 echo "/mnt$KDRVCONF." >> $RECOVERFILE 1387c478bd9Sstevel@tonic-gate else 139*60fffc19Sjw149990 echo "\tcp /mnt${SAVEDIR}/$DRVCONF /mnt$KDRVCONF" >> $RECOVERFILE 1407c478bd9Sstevel@tonic-gate fi 1417c478bd9Sstevel@tonic-gate 142*60fffc19Sjw149990 if [ $1 -ne 0 ]; then 1437c478bd9Sstevel@tonic-gate echo "\tcp /mnt${SAVEDIR}/vfstab /mnt$VFSTAB" >> $RECOVERFILE 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate echo "repository /mnt/etc/svc/repository.db" > $SVCCFG_RECOVERY 1467c478bd9Sstevel@tonic-gate echo "select $STMSINSTANCE" >> $SVCCFG_RECOVERY 1477c478bd9Sstevel@tonic-gate echo "setprop general/enabled=false" >> $SVCCFG_RECOVERY 1487c478bd9Sstevel@tonic-gate echo "exit" >> $SVCCFG_RECOVERY 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate echo "\t/usr/sbin/svccfg -f /mnt$SVCCFG_RECOVERY" >> $RECOVERFILE 1515a4c37c9Sqh201292 1525a4c37c9Sqh201292 if [ "x$MACH" = "xi386" -a "x$new_bootpath" != "x" ]; then 1535a4c37c9Sqh201292 echo "\tcp /mnt${SAVEDIR}/bootenv.rc /mnt$BOOTENV_FILE" >> $RECOVERFILE 1545a4c37c9Sqh201292 fi 1557c478bd9Sstevel@tonic-gate fi 1567c478bd9Sstevel@tonic-gate 157*60fffc19Sjw149990 rootdisk=`$MOUNT | $GREP "/ on " | cut -f 3 -d " "` 1587c478bd9Sstevel@tonic-gate echo "\tumount /mnt\n\treboot\n\n${rootdisk} \c" >> $RECOVERFILE 1597c478bd9Sstevel@tonic-gate gettext "was your root device,\nbut it could be named differently after you boot net.\n" >> $RECOVERFILE 1607c478bd9Sstevel@tonic-gate} 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate# 1637c478bd9Sstevel@tonic-gate# Arrange for /etc/vfstab and dump configuration to be updated 1647c478bd9Sstevel@tonic-gate# during the next reboot. If the cmd is "enable" or "disable", copy 165*60fffc19Sjw149990# $TMPDRVCONF to $KDRVCONF. 1667c478bd9Sstevel@tonic-gate# 1677c478bd9Sstevel@tonic-gate# Returns 0 on success, 1 on failure. 1687c478bd9Sstevel@tonic-gate# 1697c478bd9Sstevel@tonic-gateupdate_sysfiles() 1707c478bd9Sstevel@tonic-gate{ 171*60fffc19Sjw149990 1727c478bd9Sstevel@tonic-gate gettext "WARNING: This operation will require a reboot.\nDo you want to continue ? [y/n] (default: y) " 1737c478bd9Sstevel@tonic-gate read response 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gate if [ "x$response" != x -a "x$response" != xy -a \ 1767c478bd9Sstevel@tonic-gate "x$response" != xY ]; then 177*60fffc19Sjw149990 for d in $DRVLIST; do 178*60fffc19Sjw149990 TMPDRVCONF=/var/run/tmp.$d.conf.$$ 179*60fffc19Sjw149990 rm -f $TMPDRVCONF > /dev/null 2>&1 180*60fffc19Sjw149990 done; 181*60fffc19Sjw149990 return 0; 1827c478bd9Sstevel@tonic-gate fi 1837c478bd9Sstevel@tonic-gate 184*60fffc19Sjw149990 need_bootscript="" 185*60fffc19Sjw149990 1867c478bd9Sstevel@tonic-gate if [ "x$cmd" = xenable -o "x$cmd" = xdisable ]; then 187*60fffc19Sjw149990 188*60fffc19Sjw149990 for d in $DRVLIST; do 189*60fffc19Sjw149990 DRVCONF=$d.conf 190*60fffc19Sjw149990 KDRVCONF=/kernel/drv/$d.conf 191*60fffc19Sjw149990 TMPDRVCONF=/var/run/tmp.$d.conf.$$ 192*60fffc19Sjw149990 193*60fffc19Sjw149990 cp $KDRVCONF $SAVEDIR 194*60fffc19Sjw149990 cp $TMPDRVCONF $KDRVCONF 195*60fffc19Sjw149990 rm -f $TMPDRVCONF > /dev/null 2>&1 1967c478bd9Sstevel@tonic-gate 1977c478bd9Sstevel@tonic-gate # 1987c478bd9Sstevel@tonic-gate # there is no need to update the system files in the following 1997c478bd9Sstevel@tonic-gate # cases: 2007c478bd9Sstevel@tonic-gate # - we are enabling mpxio and the system has no configured 2017c478bd9Sstevel@tonic-gate # disks accessible by phci paths. 2027c478bd9Sstevel@tonic-gate # - we are disabling mpxio and the system has no configured 2037c478bd9Sstevel@tonic-gate # disks accessible by vhci paths. 2047c478bd9Sstevel@tonic-gate # 205*60fffc19Sjw149990 206*60fffc19Sjw149990 build_parent_list $d; 207*60fffc19Sjw149990 if [ "x$CLIENT_TYPE_PHCI" = "x" ]; then 208*60fffc19Sjw149990 continue; 209*60fffc19Sjw149990 fi 210*60fffc19Sjw149990 211*60fffc19Sjw149990 if [ "x$cmd" = "xenable" ]; then 2127c478bd9Sstevel@tonic-gate ls -l /dev/dsk/*s2 2> /dev/null | \ 213*60fffc19Sjw149990 $EGREP -s "$CLIENT_TYPE_PHCI" 2147c478bd9Sstevel@tonic-gate else 2157c478bd9Sstevel@tonic-gate ls -l /dev/dsk/*s2 2> /dev/null | \ 216*60fffc19Sjw149990 $EGREP -s "$CLIENT_TYPE_VHCI" 2177c478bd9Sstevel@tonic-gate fi 2187c478bd9Sstevel@tonic-gate 2197c478bd9Sstevel@tonic-gate if [ $? -ne 0 ]; then 220*60fffc19Sjw149990 need_bootscript="$need_bootscript $d" 221*60fffc19Sjw149990 fi 222*60fffc19Sjw149990 done 223*60fffc19Sjw149990 fi 224*60fffc19Sjw149990 225*60fffc19Sjw149990 # if we're an x86/x64 machine and our bootpath is on fibrechannel 226*60fffc19Sjw149990 # then we cannot disable mpxio for that controller. Yet..... 227*60fffc19Sjw149990 # This code block is an ugly hack and when we either get full-time 228*60fffc19Sjw149990 # mpxio for all devices, or devfsadm gets re-written then we can 229*60fffc19Sjw149990 # remove it. For now, though, we have to see the beauty in ugly. 230*60fffc19Sjw149990 231*60fffc19Sjw149990 if [ "x$MACH" = "xi386" ]; then 232*60fffc19Sjw149990 BOOTPATH=`/usr/sbin/eeprom bootpath | $AWK -F"=" '{print $2}'` 233*60fffc19Sjw149990 FPBOOT=`echo "$BOOTPATH" | $GREP "/fp@"` 234*60fffc19Sjw149990 if [ ! -z "$FPBOOT" ]; then 235*60fffc19Sjw149990 NEWP=`/usr/bin/dirname $BOOTPATH` 236*60fffc19Sjw149990 NNEWP=`/usr/bin/dirname $NEWP` 237*60fffc19Sjw149990 238*60fffc19Sjw149990 # check that we haven't already got this entry 239*60fffc19Sjw149990 # in /kernel/drv/fp.conf. 240*60fffc19Sjw149990 241*60fffc19Sjw149990 EXISTP=`$GREP "^name.*$NNEWP" /kernel/drv/fp.conf` 242*60fffc19Sjw149990# if [ -z "$EXISTP" ]; then 243*60fffc19Sjw149990 if [ $? != 0 ]; then 244*60fffc19Sjw149990 cat >>/kernel/drv/fp.conf << EOF 245*60fffc19Sjw149990# This entry must be the last one in the fp.conf file 246*60fffc19Sjw149990# to ensure that the boot path mpxio setting is not 247*60fffc19Sjw149990# accidentally overridden 248*60fffc19Sjw149990name="fp" parent="$NNEWP" port=0 mpxio-disable="no"; 249*60fffc19Sjw149990EOF 250*60fffc19Sjw149990 fi 2517c478bd9Sstevel@tonic-gate fi 2527c478bd9Sstevel@tonic-gate fi 2537c478bd9Sstevel@tonic-gate 254*60fffc19Sjw149990 if [ -z "$need_bootscript" ]; then 255*60fffc19Sjw149990 need_bootscript=0 2565a4c37c9Sqh201292 if [ "x$MACH" = "xi386" -a "x$new_bootpath" != "x" ]; then 2575a4c37c9Sqh201292 #only update bootpath for x86. 2585a4c37c9Sqh201292 cp $BOOTENV_FILE $SAVEDIR 259*60fffc19Sjw149990 /usr/sbin/eeprom bootpath=$new_bootpath 2605a4c37c9Sqh201292 fi 2617c478bd9Sstevel@tonic-gate # 2627c478bd9Sstevel@tonic-gate # Enable the mpxio-upgrade service, but don't run it now. 2637c478bd9Sstevel@tonic-gate # The service will run during the next reboot and will do 2647c478bd9Sstevel@tonic-gate # the actual job of modifying the system files. 2657c478bd9Sstevel@tonic-gate # 2667c478bd9Sstevel@tonic-gate svcadm disable -t $STMSINSTANCE 2677c478bd9Sstevel@tonic-gate svccfg -f - << EOF 2687c478bd9Sstevel@tonic-gateselect $STMSINSTANCE 2697c478bd9Sstevel@tonic-gatesetprop general/enabled = true 2707c478bd9Sstevel@tonic-gateEOF 2717c478bd9Sstevel@tonic-gate fi 2727c478bd9Sstevel@tonic-gate 2737c478bd9Sstevel@tonic-gate build_recover $need_bootscript 2747c478bd9Sstevel@tonic-gate 275*60fffc19Sjw149990 if [ "x$MACH" = "xi386" ]; then 276*60fffc19Sjw149990 $BOOTADM update-archive 277*60fffc19Sjw149990 fi 278*60fffc19Sjw149990 2797c478bd9Sstevel@tonic-gate gettext "The changes will come into effect after rebooting the system.\nReboot the system now ? [y/n] (default: y) " 2807c478bd9Sstevel@tonic-gate read response 2817c478bd9Sstevel@tonic-gate 2827c478bd9Sstevel@tonic-gate if [ "x$response" = x -o "x$response" = xy -o \ 2837c478bd9Sstevel@tonic-gate "x$response" = xY ]; then 284*60fffc19Sjw149990 /usr/sbin/reboot 2857c478bd9Sstevel@tonic-gate fi 2867c478bd9Sstevel@tonic-gate 2877c478bd9Sstevel@tonic-gate return 0 2887c478bd9Sstevel@tonic-gate} 2897c478bd9Sstevel@tonic-gate 2907c478bd9Sstevel@tonic-gate# 2917c478bd9Sstevel@tonic-gate# Enable or disable mpxio as specified by the cmd. 2927c478bd9Sstevel@tonic-gate# Returns 0 on success, 1 on failure. 2937c478bd9Sstevel@tonic-gate# 294*60fffc19Sjw149990# Args: $cmd = {enable | disable} 295*60fffc19Sjw149990# $d = {fp | mpt} 296*60fffc19Sjw149990# 297*60fffc19Sjw149990# the global variable $DRVLIST is used 298*60fffc19Sjw149990# 2997c478bd9Sstevel@tonic-gateconfigure_mpxio() 3007c478bd9Sstevel@tonic-gate{ 3015a4c37c9Sqh201292 mpxiodisableno='mpxio-disable[ ]*=[ ]*"no"[ ]*;' 3025a4c37c9Sqh201292 mpxiodisableyes='mpxio-disable[ ]*=[ ]*"yes"[ ]*;' 3035a4c37c9Sqh201292 3047c478bd9Sstevel@tonic-gate if [ "x$cmd" = xenable ]; then 3055a4c37c9Sqh201292 mpxiodisable_cur_entry=$mpxiodisableyes 3067c478bd9Sstevel@tonic-gate propval=no 307*60fffc19Sjw149990 msg=`gettext "STMS already enabled"` 3087c478bd9Sstevel@tonic-gate else 3095a4c37c9Sqh201292 mpxiodisable_cur_entry=$mpxiodisableno 3107c478bd9Sstevel@tonic-gate propval=yes 311*60fffc19Sjw149990 msg=`gettext "STMS already disabled"` 3127c478bd9Sstevel@tonic-gate fi 3137c478bd9Sstevel@tonic-gate 314*60fffc19Sjw149990 DRVCONF=$d.conf 315*60fffc19Sjw149990 KDRVCONF=/kernel/drv/$d.conf 316*60fffc19Sjw149990 TMPDRVCONF=/var/run/tmp.$d.conf.$$ 317*60fffc19Sjw149990 TMPDRVCONF_MPXIO_ENTRY=/var/run/tmp.$d.conf.mpxioentry.$$; 318*60fffc19Sjw149990 319*60fffc19Sjw149990 echo "Checking mpxio status for driver $d" 320*60fffc19Sjw149990 if delete_mpxio_disable_entries $KDRVCONF $TMPDRVCONF $TMPDRVCONF_MPXIO_ENTRY; then 321*60fffc19Sjw149990 322*60fffc19Sjw149990 if [ -s $TMPDRVCONF_MPXIO_ENTRY ]; then 323*60fffc19Sjw149990 # $DRVCONF does have mpxiodisable entries 324*60fffc19Sjw149990 $EGREP -s "$mpxiodisable_cur_entry" $TMPDRVCONF_MPXIO_ENTRY 3255a4c37c9Sqh201292 if [ $? -ne 0 ]; then 3265a4c37c9Sqh201292 # if all mpxiodisable entries are no/yes for 3275a4c37c9Sqh201292 # enable/disable mpxio, notify the user 328*60fffc19Sjw149990 rm -f $TMPDRVCONF $TMPDRVCONF_MPXIO_ENTRY > /dev/null 2>&1 329*60fffc19Sjw149990 continue; 330*60fffc19Sjw149990 else 331*60fffc19Sjw149990 reboot_needed=`$EXPR $reboot_needed + 1` 3327c478bd9Sstevel@tonic-gate fi 333*60fffc19Sjw149990 334*60fffc19Sjw149990 # If mpxiodisable entries do not exist, always continue update 3355a4c37c9Sqh201292 fi 3367c478bd9Sstevel@tonic-gate else 337*60fffc19Sjw149990 rm -f $TMPDRVCONF $TMPDRVCONF_MPXIO_ENTRY > /dev/null 2>&1 3387c478bd9Sstevel@tonic-gate gettext "failed to update " 1>&2 339*60fffc19Sjw149990 echo "$KDRVCONF." 1>&2 3407c478bd9Sstevel@tonic-gate gettext "No changes were made to your STMS configuration.\n" 1>&2 3417c478bd9Sstevel@tonic-gate return 1 3427c478bd9Sstevel@tonic-gate fi 3435a4c37c9Sqh201292 344*60fffc19Sjw149990 rm $TMPDRVCONF_MPXIO_ENTRY > /dev/null 2>&1 345*60fffc19Sjw149990 echo "mpxio-disable=\"${propval}\";" >> $TMPDRVCONF 3465a4c37c9Sqh201292 3477c478bd9Sstevel@tonic-gate} 3487c478bd9Sstevel@tonic-gate 3497c478bd9Sstevel@tonic-gatesetcmd() 3507c478bd9Sstevel@tonic-gate{ 3517c478bd9Sstevel@tonic-gate if [ "x$cmd" = xnone ]; then 3527c478bd9Sstevel@tonic-gate cmd=$1 3537c478bd9Sstevel@tonic-gate else 3547c478bd9Sstevel@tonic-gate echo "$USAGE" 1>&2 3557c478bd9Sstevel@tonic-gate exit 2 3567c478bd9Sstevel@tonic-gate fi 3577c478bd9Sstevel@tonic-gate} 3587c478bd9Sstevel@tonic-gate 359*60fffc19Sjw149990# 3605a4c37c9Sqh201292#Need to update bootpath on x86 if boot system from FC disk 3615a4c37c9Sqh201292#Only update bootpath here when mpxio is enabled 3625a4c37c9Sqh201292#If mpxio is disabled currently, will update bootpath in mpxio-upgrade 363*60fffc19Sjw149990# 364*60fffc19Sjw149990 3655a4c37c9Sqh201292get_newbootpath_for_stmsdev() { 3665a4c37c9Sqh201292 if [ "x$cmd" = "xenable" ]; then 3675a4c37c9Sqh201292 return 0 3685a4c37c9Sqh201292 fi 3695a4c37c9Sqh201292 370*60fffc19Sjw149990 cur_bootpath=`eeprom bootpath | \ 371*60fffc19Sjw149990 sed 's/bootpath=[ ]*//g' | sed 's/[ ]*$//'` 3725a4c37c9Sqh201292 if [ "x$cur_bootpath" = "x" ]; then 3735a4c37c9Sqh201292 gettext "failed to get bootpath by eeprom\n" 1>&2 3745a4c37c9Sqh201292 return 1 3755a4c37c9Sqh201292 fi 3765a4c37c9Sqh201292 3775a4c37c9Sqh201292 #only update bootpath for STMS path 378*60fffc19Sjw149990 echo $cur_bootpath|$EGREP $CLIENT_TYPE_VHCI > /dev/null 2>&1 3795a4c37c9Sqh201292 if [ $? -eq 1 ]; then 3805a4c37c9Sqh201292 return 0 3815a4c37c9Sqh201292 fi 3825a4c37c9Sqh201292 3835a4c37c9Sqh201292 new_bootpath=`$STMSBOOTUTIL -p /devices$cur_bootpath` 3845a4c37c9Sqh201292 if [ $? -ne 0 ]; then 3855a4c37c9Sqh201292 new_bootpath="" 3865a4c37c9Sqh201292 return 1 3875a4c37c9Sqh201292 fi 388*60fffc19Sjw149990 389*60fffc19Sjw149990 # we replace "sd" with "disk" if we need to work on the eeprom 390*60fffc19Sjw149990 # bootpath setting, since fibre-channel devices will report as 391*60fffc19Sjw149990 # being attached via "disk" and not "sd". One day we'll have a 392*60fffc19Sjw149990 # truly unified and architecture-independent view of the device 393*60fffc19Sjw149990 # tree, and this block will be redundant 394*60fffc19Sjw149990 fp_bootpath=`echo $new_bootpath|grep fp.*sd` 395*60fffc19Sjw149990 if [ "x$fp_bootpath" != "x" ]; then 396*60fffc19Sjw149990 new_bootpath=`echo $fp_bootpath |sed -e"s,sd,disk,g"` 397*60fffc19Sjw149990 fi 398*60fffc19Sjw149990} 399*60fffc19Sjw149990 400*60fffc19Sjw149990# 401*60fffc19Sjw149990# Emit a warning message to the user that by default we 402*60fffc19Sjw149990# operate on all multipath-capable controllers that are 403*60fffc19Sjw149990# attached to the system, and that if they want to operate 404*60fffc19Sjw149990# on only a specific controller type (fp|mpt|....) then 405*60fffc19Sjw149990# they need to re-invoke stmsboot with "-D $driver" in 406*60fffc19Sjw149990# their argument list 407*60fffc19Sjw149990# 408*60fffc19Sjw149990 409*60fffc19Sjw149990emit_driver_warning_msg() { 410*60fffc19Sjw149990 411*60fffc19Sjw149990 # for each driver that we support, grab the list 412*60fffc19Sjw149990 # of controllers attached to the system. 413*60fffc19Sjw149990 414*60fffc19Sjw149990 echo "WARNING: stmsboot operates on each supported multipath-capable controller" 415*60fffc19Sjw149990 echo " detected in a host. In your system, these controllers are" 416*60fffc19Sjw149990 417*60fffc19Sjw149990 for WARNDRV in fp mpt; do 418*60fffc19Sjw149990 $GREP "$WARNDRV.$" /etc/path_to_inst | $AWK -F"\"" '{print "/devices"$2}' 419*60fffc19Sjw149990 done; 420*60fffc19Sjw149990 421*60fffc19Sjw149990 echo "" 422*60fffc19Sjw149990 echo "If you do NOT wish to operate on these controllers, please quit stmsboot" 423*60fffc19Sjw149990 echo "and re-invoke with -D { fp | mpt } to specify which controllers you wish" 424*60fffc19Sjw149990 echo "to modify your multipathing configuration for." 425*60fffc19Sjw149990 426*60fffc19Sjw149990 echo 427*60fffc19Sjw149990 gettext "Do you wish to continue? [y/n] (default: y) " 1>&2 428*60fffc19Sjw149990 read response 429*60fffc19Sjw149990 430*60fffc19Sjw149990 if [ "x$response" -ne "xY" -a "x$response" -ne "xy" ]; then 431*60fffc19Sjw149990 exit 432*60fffc19Sjw149990 fi 433*60fffc19Sjw149990 434*60fffc19Sjw149990} 435*60fffc19Sjw149990 436*60fffc19Sjw149990# Function to setup the CLIENT_TYPE_PHCI string based on 437*60fffc19Sjw149990# the list of drivers that we're operating on. The variable 438*60fffc19Sjw149990# depends upon the pathname of the parent node in the 439*60fffc19Sjw149990# device tree, which can be different on x86/x64 and sparc. 440*60fffc19Sjw149990# Oh, if we only had OBP on x86/x64! 441*60fffc19Sjw149990build_parent_list() { 442*60fffc19Sjw149990 443*60fffc19Sjw149990 # stmsboot_util -n provides us with the name of the 444*60fffc19Sjw149990 # node containing "fp" or "sas-$d", and helpfully 445*60fffc19Sjw149990 # appends "/[ssd|sd]@" as appropriate 446*60fffc19Sjw149990 447*60fffc19Sjw149990 d=$1; 448*60fffc19Sjw149990 449*60fffc19Sjw149990 TLIST=`$STMSBOOTUTIL -D $d -n` 450*60fffc19Sjw149990 if [ "x$TLIST" != "x" ]; then 451*60fffc19Sjw149990 CLIENT_TYPE_PHCI="$TLIST|$CLIENT_TYPE_PHCI" 452*60fffc19Sjw149990 else 453*60fffc19Sjw149990 CLIENT_TYPE_PHCI="$CLIENT_TYPE_PHCI" 454*60fffc19Sjw149990 fi 4555a4c37c9Sqh201292} 4565a4c37c9Sqh201292 4575a4c37c9Sqh201292 4587c478bd9Sstevel@tonic-gatecmd=none 4597c478bd9Sstevel@tonic-gate 4607c478bd9Sstevel@tonic-gate# process options 461*60fffc19Sjw149990while getopts D:geduLl: c 4627c478bd9Sstevel@tonic-gatedo 4637c478bd9Sstevel@tonic-gate case $c in 4647c478bd9Sstevel@tonic-gate e) setcmd enable;; 4657c478bd9Sstevel@tonic-gate d) setcmd disable;; 4667c478bd9Sstevel@tonic-gate u) setcmd update;; 4677c478bd9Sstevel@tonic-gate L) setcmd listall;; 4687c478bd9Sstevel@tonic-gate l) setcmd list 4697c478bd9Sstevel@tonic-gate controller=$OPTARG;; 470*60fffc19Sjw149990 D) DRV=$OPTARG;; 471*60fffc19Sjw149990 g) GUID="-g";; 4727c478bd9Sstevel@tonic-gate \?) echo "$USAGE" 1>&2 4737c478bd9Sstevel@tonic-gate exit 2;; 4747c478bd9Sstevel@tonic-gate esac 4757c478bd9Sstevel@tonic-gatedone 4767c478bd9Sstevel@tonic-gate 4777c478bd9Sstevel@tonic-gateif [ "x$cmd" = xnone ]; then 4787c478bd9Sstevel@tonic-gate echo "$USAGE" 1>&2 4797c478bd9Sstevel@tonic-gate exit 2 4807c478bd9Sstevel@tonic-gatefi 4817c478bd9Sstevel@tonic-gate 482*60fffc19Sjw149990if [ "x$DRV" = "x" ]; then 483*60fffc19Sjw149990 DRVLIST="fp mpt" 484*60fffc19Sjw149990else 485*60fffc19Sjw149990 DRVLIST=$DRV 486*60fffc19Sjw149990fi 487*60fffc19Sjw149990 488*60fffc19Sjw149990 489*60fffc19Sjw149990STMSPRIVS=`/usr/bin/ppriv $$ | $EGREP "E:.*all|E:.*sys_devices"` 490*60fffc19Sjw149990USERID=`id` 491*60fffc19Sjw149990if [ "$USERID" != "uid=0(root) gid=0(root)" ] -o [ "x$STMSPRIVS" == "x" ]; then 4927c478bd9Sstevel@tonic-gate gettext "You must be super-user to run this script.\n" 1>&2 4937c478bd9Sstevel@tonic-gate exit 1 4947c478bd9Sstevel@tonic-gatefi 4957c478bd9Sstevel@tonic-gate 4967c478bd9Sstevel@tonic-gate# just a sanity check 4977c478bd9Sstevel@tonic-gateif [ ! -f $STMSBOOTUTIL -o ! -f $STMSMETHODSCRIPT ]; then 4987c478bd9Sstevel@tonic-gate fmt=`gettext "Can't find %s and/or %s"` 4997c478bd9Sstevel@tonic-gate printf "$fmt\n" "$STMSBOOTUTIL" "$STMSMETHODSCRIPT" 1>&2 5007c478bd9Sstevel@tonic-gate exit 1 5017c478bd9Sstevel@tonic-gatefi 5027c478bd9Sstevel@tonic-gate 503*60fffc19Sjw149990# If the old sun4u-specific SMF method is found, remove it 504*60fffc19Sjw149990/usr/sbin/svccfg -s "platform/sun4u/mpxio-upgrade:default" < /dev/null > /dev/null 2>&1 5057c478bd9Sstevel@tonic-gateif [ $? -ne 0 ]; then 506*60fffc19Sjw149990 /usr/sbin/svccfg delete "platform/sun4u/mpxio-upgrade:default" > /dev/null 2>&1 507*60fffc19Sjw149990fi 508*60fffc19Sjw149990 509*60fffc19Sjw149990# now import the new service, if necessary 510*60fffc19Sjw149990/usr/bin/svcprop -q $STMSINSTANCE < /dev/null > /dev/null 2>&1 511*60fffc19Sjw149990if [ $? -ne 0 ]; then 512*60fffc19Sjw149990 if [ -f /var/svc/manifest/system/device/mpxio-upgrade.xml ]; then 513*60fffc19Sjw149990 /usr/sbin/svccfg import /var/svc/manifest/system/device/mpxio-upgrade.xml 514*60fffc19Sjw149990 if [ $? -ne 0 ]; then 515*60fffc19Sjw149990 fmt=`gettext "Unable to import %s service"` 5167c478bd9Sstevel@tonic-gate printf "$fmt\n" "$STMSINSTANCE" 1>&2 5177c478bd9Sstevel@tonic-gate exit 1 518*60fffc19Sjw149990 else 519*60fffc19Sjw149990 fmt=`gettext "Service %s imported successfully, continuing"` 520*60fffc19Sjw149990 printf "$fmt\n" "$STMSINSTANCE" 1>&2 521*60fffc19Sjw149990 fi 522*60fffc19Sjw149990 else 523*60fffc19Sjw149990 fmt=`gettext "Service %s does not exist on this host"` 524*60fffc19Sjw149990 printf "$fmt\n" "$STMSINSTANCE" 1>&2 525*60fffc19Sjw149990 exit 1 526*60fffc19Sjw149990 fi 5277c478bd9Sstevel@tonic-gatefi 5287c478bd9Sstevel@tonic-gate 5297c478bd9Sstevel@tonic-gateif [ "x$cmd" = xenable -o "x$cmd" = xdisable -o "x$cmd" = xupdate ]; then 5307c478bd9Sstevel@tonic-gate # 5317c478bd9Sstevel@tonic-gate # The bootup script doesn't work on cache-only-clients as the script 5326deb031bSsjelinek # is executed before the plumbing for cachefs mounting of root is done. 5337c478bd9Sstevel@tonic-gate # 534*60fffc19Sjw149990 if $MOUNT -v | $EGREP -s " on / type (nfs|cachefs) "; then 5357c478bd9Sstevel@tonic-gate gettext "This command option is not supported on systems with nfs or cachefs mounted root filesystem.\n" 1>&2 5367c478bd9Sstevel@tonic-gate exit 1 5377c478bd9Sstevel@tonic-gate fi 5387c478bd9Sstevel@tonic-gate 5397c478bd9Sstevel@tonic-gate if [ -d $SAVEDIR ]; then 5407c478bd9Sstevel@tonic-gate # 5417c478bd9Sstevel@tonic-gate # keep a copy of the last saved files, useful for manual 5427c478bd9Sstevel@tonic-gate # recovery in case of a problem. 5437c478bd9Sstevel@tonic-gate # 544*60fffc19Sjw149990 for d in $DRVLIST; do 545*60fffc19Sjw149990 DRVCONF=$d.conf 546*60fffc19Sjw149990 KDRVCONF=/kernel/drv/$d.conf 547*60fffc19Sjw149990 TMPDRVCONF=/var/run/tmp.$d.conf.$$ 548*60fffc19Sjw149990 TMPDRVCONF_MPXIO_ENTRY=/var/run/tmp.$d.conf.mpxioentry.$$; 549*60fffc19Sjw149990 5505a4c37c9Sqh201292 if [ "x$MACH" = "xsparc" ]; then 551*60fffc19Sjw149990 backup_lastsaved $KDRVCONF $VFSTAB 5527c478bd9Sstevel@tonic-gate else 553*60fffc19Sjw149990 backup_lastsaved $KDRVCONF $VFSTAB $BOOTENV_FILE 5545a4c37c9Sqh201292 fi 555*60fffc19Sjw149990 done 5565a4c37c9Sqh201292 else 5577c478bd9Sstevel@tonic-gate mkdir $SAVEDIR 5587c478bd9Sstevel@tonic-gate fi 5597c478bd9Sstevel@tonic-gate 5607c478bd9Sstevel@tonic-gatefi 5617c478bd9Sstevel@tonic-gate 5627c478bd9Sstevel@tonic-gateif [ "x$cmd" = xenable -o "x$cmd" = xdisable ]; then 563*60fffc19Sjw149990 564*60fffc19Sjw149990 msgneeded=`echo "$DRVLIST" |grep " "` 565*60fffc19Sjw149990 if [ -n "$msgneeded" ]; then 566*60fffc19Sjw149990 emit_driver_warning_msg 567*60fffc19Sjw149990 fi 568*60fffc19Sjw149990 for d in $DRVLIST; do 569*60fffc19Sjw149990 configure_mpxio $cmd $d 570*60fffc19Sjw149990 done 571*60fffc19Sjw149990 572*60fffc19Sjw149990 if [ $reboot_needed -ne 0 ]; then 573*60fffc19Sjw149990 574*60fffc19Sjw149990 # Need to update bootpath on x86 if our boot device is 575*60fffc19Sjw149990 # now accessed through mpxio. 576*60fffc19Sjw149990 # Only update bootpath before reboot when mpxio is enabled 577*60fffc19Sjw149990 # If mpxio is currently disabled, we will update bootpath 578*60fffc19Sjw149990 # on reboot in the mpxio-upgrade service 579*60fffc19Sjw149990 580*60fffc19Sjw149990 if [ "x$MACH" = "xi386" -a "x$cmd" = "xdisable" ]; then 581*60fffc19Sjw149990 get_newbootpath_for_stmsdev 582*60fffc19Sjw149990 if [ $? -ne 0 ]; then 583*60fffc19Sjw149990 rm -f $TMPDRVCONF > /dev/null 2>&1 584*60fffc19Sjw149990 gettext "failed to update bootpath.\n" 1>&2 585*60fffc19Sjw149990 gettext "No changes were made to your STMS configuration.\n" 1>&2 586*60fffc19Sjw149990 return 1 587*60fffc19Sjw149990 fi 588*60fffc19Sjw149990 fi 589*60fffc19Sjw149990 update_sysfiles 590*60fffc19Sjw149990 else 591*60fffc19Sjw149990 echo "STMS is already ${cmd}d. No changes or reboots needed" 592*60fffc19Sjw149990 fi 593*60fffc19Sjw149990 594*60fffc19Sjw149990 5957c478bd9Sstevel@tonic-gateelif [ "x$cmd" = xupdate ]; then 5965a4c37c9Sqh201292 if [ "x$MACH" = "xi386" ]; then 5975a4c37c9Sqh201292 # In this case we always change the bootpath to phci-based 5985a4c37c9Sqh201292 # path first. bootpath will later be modified in mpxio-upgrade 5995a4c37c9Sqh201292 # to the vhci-based path if mpxio is enabled on root. 6005a4c37c9Sqh201292 get_newbootpath_for_stmsdev 6015a4c37c9Sqh201292 if [ $? -ne 0 ]; then 6025a4c37c9Sqh201292 gettext "failed to update bootpath.\n" 1>&2 6035a4c37c9Sqh201292 return 1 6045a4c37c9Sqh201292 fi 6055a4c37c9Sqh201292 fi 6067c478bd9Sstevel@tonic-gate update_sysfiles 607*60fffc19Sjw149990 6087c478bd9Sstevel@tonic-gateelif [ "x$cmd" = xlist ]; then 609*60fffc19Sjw149990 $STMSBOOTUTIL $GUID -l $controller 6107c478bd9Sstevel@tonic-gateelse 611*60fffc19Sjw149990 $STMSBOOTUTIL $GUID -L 6127c478bd9Sstevel@tonic-gatefi 6137c478bd9Sstevel@tonic-gate 6147c478bd9Sstevel@tonic-gateexit $? 615