1*a0261a43SJames 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# 23*a0261a43SJames C. McPherson# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate# Use is subject to license terms. 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= 3460fffc19Sjw149990DRVLIST= 3560fffc19Sjw149990GUID= 367c478bd9Sstevel@tonic-gateVFSTAB=/etc/vfstab 377c478bd9Sstevel@tonic-gateSAVEDIR=/etc/mpxio 387c478bd9Sstevel@tonic-gateRECOVERFILE=$SAVEDIR/recover_instructions 397c478bd9Sstevel@tonic-gateSVCCFG_RECOVERY=$SAVEDIR/svccfg_recover 4060fffc19Sjw149990SUPPORTED_DRIVERS="fp|mpt" 4160fffc19Sjw149990USAGE=`gettext "Usage: stmsboot [-D $SUPPORTED_DRIVERS] -e | -d | -u | -L | -l controller_number"` 42aca6e9ccSramatTEXTDOMAIN=SUNW_OST_OSCMD 43aca6e9ccSramatexport TEXTDOMAIN 44*a0261a43SJames C. McPhersonSTMSINSTANCE=svc:system/device/mpxio-upgrade:default 4560fffc19Sjw149990STMSBOOT=/usr/sbin/stmsboot 4660fffc19Sjw149990BOOTADM=/sbin/bootadm 4760fffc19Sjw149990MOUNT=/usr/sbin/mount 48*a0261a43SJames C. McPhersonEEPROM=/usr/sbin/eeprom 4960fffc19Sjw149990EGREP=/usr/bin/egrep 5060fffc19Sjw149990GREP=/usr/bin/grep 5160fffc19Sjw149990AWK=/usr/bin/awk 52*a0261a43SJames C. McPhersonCP=/usr/bin/cp 53*a0261a43SJames C. McPhersonLS=/usr/bin/ls 54*a0261a43SJames C. McPhersonMV=/usr/bin/mv 55*a0261a43SJames C. McPhersonRM=/usr/bin/rm 5660fffc19Sjw149990SORT=/usr/bin/sort 5760fffc19Sjw149990UNIQ=/usr/bin/uniq 5860fffc19Sjw149990EXPR=/usr/bin/expr 59*a0261a43SJames C. McPhersonMKDIR=/usr/bin/mkdir 60*a0261a43SJames C. McPhersonREBOOT=/usr/sbin/reboot 61815dd917SjmcpSED=/usr/bin/sed 62815dd917SjmcpSVCPROP=/usr/bin/svcprop 63815dd917SjmcpSVCCFG=/usr/sbin/svccfg 64815dd917SjmcpSVCS=/usr/bin/svcs 65815dd917SjmcpSVCADM=/usr/sbin/svcadm 667c478bd9Sstevel@tonic-gate 67*a0261a43SJames C. McPhersonNOW=`/usr/bin/date +%G%m%d_%H%M` 685a4c37c9Sqh201292MACH=`/usr/bin/uname -p` 69*a0261a43SJames C. McPhersonBOOTENV_FILE=bootenv.rc 7060fffc19Sjw149990reboot_needed=0 71*a0261a43SJames C. McPhersonnew_bootpath="" 72*a0261a43SJames C. McPhersonCLIENT_TYPE_PHCI="" 73*a0261a43SJames C. McPhersonCLIENT_TYPE_VHCI="/scsi_vhci" 7460fffc19Sjw149990 757c478bd9Sstevel@tonic-gate# 7660fffc19Sjw149990# Copy all entries (including comments) from source driver.conf 7760fffc19Sjw149990# to destination driver.conf except those entries which contain 7860fffc19Sjw149990# the mpxio-disable property. 797c478bd9Sstevel@tonic-gate# Take into consideration entries that spawn more than one line. 807c478bd9Sstevel@tonic-gate# 817c478bd9Sstevel@tonic-gate# $1 source driver.conf file 827c478bd9Sstevel@tonic-gate# $2 destination driver.conf file 837c478bd9Sstevel@tonic-gate# 847c478bd9Sstevel@tonic-gate# Returns 0 on success, non zero on failure. 857c478bd9Sstevel@tonic-gate# 867c478bd9Sstevel@tonic-gatedelete_mpxio_disable_entries() 877c478bd9Sstevel@tonic-gate{ 88*a0261a43SJames C. McPherson # be careful here, we've got embedded \t characters 89*a0261a43SJames C. McPherson # in sed's pattern space. 90*a0261a43SJames C. McPherson $SED ' 917c478bd9Sstevel@tonic-gate /^[ ]*#/{ p 927c478bd9Sstevel@tonic-gate d 937c478bd9Sstevel@tonic-gate } 947c478bd9Sstevel@tonic-gate s/[ ]*$// 957c478bd9Sstevel@tonic-gate /^$/{ p 967c478bd9Sstevel@tonic-gate d 977c478bd9Sstevel@tonic-gate } 985a4c37c9Sqh201292 /mpxio-disable[ ]*=.*;$/{ w '$3' 995a4c37c9Sqh201292 d 1005a4c37c9Sqh201292 } 1017c478bd9Sstevel@tonic-gate /;$/{ p 1027c478bd9Sstevel@tonic-gate d 1037c478bd9Sstevel@tonic-gate } 1047c478bd9Sstevel@tonic-gate :rdnext 1057c478bd9Sstevel@tonic-gate N 1067c478bd9Sstevel@tonic-gate s/[ ]*$// 1077c478bd9Sstevel@tonic-gate /[^;]$/b rdnext 1085a4c37c9Sqh201292 /mpxio-disable[ ]*=/{ s/\n/ /g 1095a4c37c9Sqh201292 w '$3' 1105a4c37c9Sqh201292 d 1115a4c37c9Sqh201292 } 1125a4c37c9Sqh201292 ' $1 > $2 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate return $? 1157c478bd9Sstevel@tonic-gate} 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate# 1187c478bd9Sstevel@tonic-gate# backup the last saved copy of the specified files. 1197c478bd9Sstevel@tonic-gate# $* files to backup 1207c478bd9Sstevel@tonic-gate# 1217c478bd9Sstevel@tonic-gatebackup_lastsaved() 1227c478bd9Sstevel@tonic-gate{ 1237c478bd9Sstevel@tonic-gate for file in $* 1247c478bd9Sstevel@tonic-gate do 125*a0261a43SJames C. McPherson newfile=`basename $file` 126*a0261a43SJames C. McPherson $CP $file $SAVEDIR/$newfile.$cmd.$NOW 1277c478bd9Sstevel@tonic-gate done 1287c478bd9Sstevel@tonic-gate} 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate# 1317c478bd9Sstevel@tonic-gate# build recover instructions 1327c478bd9Sstevel@tonic-gate# 1337c478bd9Sstevel@tonic-gate# $1 1 to include boot script in the instructions 1347c478bd9Sstevel@tonic-gate# 0 otherwise 1357c478bd9Sstevel@tonic-gate# 1367c478bd9Sstevel@tonic-gatebuild_recover() 1377c478bd9Sstevel@tonic-gate{ 1387c478bd9Sstevel@tonic-gate gettext "Instructions to recover your previous STMS configuration (if in case the system does not boot):\n\n" > $RECOVERFILE 1397c478bd9Sstevel@tonic-gate echo "\tboot net \c" >> $RECOVERFILE 1407c478bd9Sstevel@tonic-gate gettext "(or from a cd/dvd/another disk)\n" >> $RECOVERFILE 1417c478bd9Sstevel@tonic-gate echo "\tfsck <your-root-device>" >> $RECOVERFILE 1427c478bd9Sstevel@tonic-gate echo "\tmount <your-root-device> /mnt" >> $RECOVERFILE 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate if [ "x$cmd" = xupdate ]; then 1457c478bd9Sstevel@tonic-gate gettext "\tUndo the modifications you made to STMS configuration.\n\tFor example undo any changes you made to " >> $RECOVERFILE 14660fffc19Sjw149990 echo "/mnt$KDRVCONF." >> $RECOVERFILE 1477c478bd9Sstevel@tonic-gate else 148*a0261a43SJames C. McPherson echo "\tcp /mnt${SAVEDIR}/$DRVCONF.$cmd.$NOW /mnt$KDRVCONF" >> $RECOVERFILE 1497c478bd9Sstevel@tonic-gate fi 1507c478bd9Sstevel@tonic-gate 151815dd917Sjmcp if [ $1 -eq 1 ]; then 152*a0261a43SJames C. McPherson echo "\tcp /mnt${SAVEDIR}/vfstab.$cmd.$NOW /mnt$VFSTAB" >> $RECOVERFILE 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate echo "repository /mnt/etc/svc/repository.db" > $SVCCFG_RECOVERY 1557c478bd9Sstevel@tonic-gate echo "select $STMSINSTANCE" >> $SVCCFG_RECOVERY 1567c478bd9Sstevel@tonic-gate echo "setprop general/enabled=false" >> $SVCCFG_RECOVERY 1577c478bd9Sstevel@tonic-gate echo "exit" >> $SVCCFG_RECOVERY 1587c478bd9Sstevel@tonic-gate 159815dd917Sjmcp echo "\t$SVCCFG -f /mnt$SVCCFG_RECOVERY" >> $RECOVERFILE 1605a4c37c9Sqh201292 1615a4c37c9Sqh201292 if [ "x$MACH" = "xi386" -a "x$new_bootpath" != "x" ]; then 162*a0261a43SJames C. McPherson echo "\tcp /mnt${SAVEDIR}/bootenv.rc.$cmd.$NOW /mnt/boot/solaris/$BOOTENV_FILE" >> $RECOVERFILE 1635a4c37c9Sqh201292 fi 1647c478bd9Sstevel@tonic-gate fi 1657c478bd9Sstevel@tonic-gate 16660fffc19Sjw149990 rootdisk=`$MOUNT | $GREP "/ on " | cut -f 3 -d " "` 1677c478bd9Sstevel@tonic-gate echo "\tumount /mnt\n\treboot\n\n${rootdisk} \c" >> $RECOVERFILE 1687c478bd9Sstevel@tonic-gate gettext "was your root device,\nbut it could be named differently after you boot net.\n" >> $RECOVERFILE 1697c478bd9Sstevel@tonic-gate} 1707c478bd9Sstevel@tonic-gate 171*a0261a43SJames C. McPherson 1727c478bd9Sstevel@tonic-gate# 1737c478bd9Sstevel@tonic-gate# Arrange for /etc/vfstab and dump configuration to be updated 1747c478bd9Sstevel@tonic-gate# during the next reboot. If the cmd is "enable" or "disable", copy 17560fffc19Sjw149990# $TMPDRVCONF to $KDRVCONF. 1767c478bd9Sstevel@tonic-gate# 1777c478bd9Sstevel@tonic-gate# Returns 0 on success, 1 on failure. 1787c478bd9Sstevel@tonic-gate# 1797c478bd9Sstevel@tonic-gateupdate_sysfiles() 1807c478bd9Sstevel@tonic-gate{ 18160fffc19Sjw149990 182*a0261a43SJames C. McPherson gettext "WARNING: This operation will require a reboot.\n" 183*a0261a43SJames C. McPherson gettext "Do you want to continue ? [y/n] (default: y) " 1847c478bd9Sstevel@tonic-gate read response 1857c478bd9Sstevel@tonic-gate 1867c478bd9Sstevel@tonic-gate if [ "x$response" != x -a "x$response" != xy -a \ 1877c478bd9Sstevel@tonic-gate "x$response" != xY ]; then 18860fffc19Sjw149990 for d in $DRVLIST; do 18960fffc19Sjw149990 TMPDRVCONF=/var/run/tmp.$d.conf.$$ 190*a0261a43SJames C. McPherson $RM -f $TMPDRVCONF > /dev/null 2>&1 19160fffc19Sjw149990 done; 19260fffc19Sjw149990 return 0; 1937c478bd9Sstevel@tonic-gate fi 1947c478bd9Sstevel@tonic-gate 195815dd917Sjmcp # set need_bootscript to the number of drivers that 196815dd917Sjmcp # we support. 197815dd917Sjmcp need_bootscript=`echo $SUPPORTED_DRIVERS|$AWK -F"|" '{print NF}'` 19860fffc19Sjw149990 1997c478bd9Sstevel@tonic-gate if [ "x$cmd" = xenable -o "x$cmd" = xdisable ]; then 20060fffc19Sjw149990 20160fffc19Sjw149990 for d in $DRVLIST; do 20260fffc19Sjw149990 DRVCONF=$d.conf 20360fffc19Sjw149990 KDRVCONF=/kernel/drv/$d.conf 20460fffc19Sjw149990 TMPDRVCONF=/var/run/tmp.$d.conf.$$ 20560fffc19Sjw149990 206*a0261a43SJames C. McPherson $CP $KDRVCONF $SAVEDIR/`basename $KDRVCONF`.$cmd.$NOW 207815dd917Sjmcp if [ -f $TMPDRVCONF ]; then 208*a0261a43SJames C. McPherson $CP $TMPDRVCONF $KDRVCONF 209*a0261a43SJames C. McPherson $RM -f $TMPDRVCONF 210815dd917Sjmcp else 211815dd917Sjmcp # if $TMPDRVCONF doesn't exist, then we 212815dd917Sjmcp # haven't made any changes to it 213815dd917Sjmcp continue; 214815dd917Sjmcp fi 2157c478bd9Sstevel@tonic-gate 2167c478bd9Sstevel@tonic-gate # 2177c478bd9Sstevel@tonic-gate # there is no need to update the system files in the following 2187c478bd9Sstevel@tonic-gate # cases: 2197c478bd9Sstevel@tonic-gate # - we are enabling mpxio and the system has no configured 2207c478bd9Sstevel@tonic-gate # disks accessible by phci paths. 2217c478bd9Sstevel@tonic-gate # - we are disabling mpxio and the system has no configured 2227c478bd9Sstevel@tonic-gate # disks accessible by vhci paths. 2237c478bd9Sstevel@tonic-gate # 22460fffc19Sjw149990 225815dd917Sjmcp # Function to setup the CLIENT_TYPE_PHCI string based on 226815dd917Sjmcp # the list of drivers that we're operating on. The variable 227815dd917Sjmcp # depends upon the pathname of the parent node in the 228815dd917Sjmcp # device tree, which can be different on x86/x64 and sparc. 229815dd917Sjmcp 230*a0261a43SJames C. McPherson CLIENT_TYPE_PHCI=`$STMSBOOTUTIL -D $d -N`; 231815dd917Sjmcp 23260fffc19Sjw149990 if [ "x$CLIENT_TYPE_PHCI" = "x" ]; then 23360fffc19Sjw149990 continue; 23460fffc19Sjw149990 fi 23560fffc19Sjw149990 23660fffc19Sjw149990 if [ "x$cmd" = "xenable" ]; then 237*a0261a43SJames C. McPherson $LS -l /dev/dsk/*s2 2> /dev/null | \ 23860fffc19Sjw149990 $EGREP -s "$CLIENT_TYPE_PHCI" 2397c478bd9Sstevel@tonic-gate else 240*a0261a43SJames C. McPherson $LS -l /dev/dsk/*s2 2> /dev/null | \ 24160fffc19Sjw149990 $EGREP -s "$CLIENT_TYPE_VHCI" 2427c478bd9Sstevel@tonic-gate fi 2437c478bd9Sstevel@tonic-gate 2447c478bd9Sstevel@tonic-gate if [ $? -ne 0 ]; then 245815dd917Sjmcp need_bootscript=`$EXPR $need_bootscript - 1` 24660fffc19Sjw149990 fi 24760fffc19Sjw149990 done 24860fffc19Sjw149990 fi 24960fffc19Sjw149990 250815dd917Sjmcp if [ $need_bootscript -gt 0 ]; then 251815dd917Sjmcp need_bootscript=1 2525a4c37c9Sqh201292 if [ "x$MACH" = "xi386" -a "x$new_bootpath" != "x" ]; then 2535a4c37c9Sqh201292 #only update bootpath for x86. 254*a0261a43SJames C. McPherson $CP /boot/solaris/$BOOTENV_FILE $SAVEDIR/$BOOTENV_FILE.$cmd.$NOW 255*a0261a43SJames C. McPherson $EEPROM bootpath="$new_bootpath" 2565a4c37c9Sqh201292 fi 257*a0261a43SJames C. McPherson # Enable the mpxio-upgrade service for the reboot 258815dd917Sjmcp $SVCADM disable -t $STMSINSTANCE 259*a0261a43SJames C. McPherson $SVCCFG -s $STMSINSTANCE "setprop general/enabled=true" 260815dd917Sjmcp else 261815dd917Sjmcp need_bootscript=0 2627c478bd9Sstevel@tonic-gate fi 2637c478bd9Sstevel@tonic-gate 2647c478bd9Sstevel@tonic-gate build_recover $need_bootscript 2657c478bd9Sstevel@tonic-gate 26660fffc19Sjw149990 if [ "x$MACH" = "xi386" ]; then 26760fffc19Sjw149990 $BOOTADM update-archive 26860fffc19Sjw149990 fi 26960fffc19Sjw149990 2707c478bd9Sstevel@tonic-gate gettext "The changes will come into effect after rebooting the system.\nReboot the system now ? [y/n] (default: y) " 2717c478bd9Sstevel@tonic-gate read response 2727c478bd9Sstevel@tonic-gate 2737c478bd9Sstevel@tonic-gate if [ "x$response" = x -o "x$response" = xy -o \ 2747c478bd9Sstevel@tonic-gate "x$response" = xY ]; then 275*a0261a43SJames C. McPherson $REBOOT 2767c478bd9Sstevel@tonic-gate fi 2777c478bd9Sstevel@tonic-gate 2787c478bd9Sstevel@tonic-gate return 0 2797c478bd9Sstevel@tonic-gate} 2807c478bd9Sstevel@tonic-gate 281*a0261a43SJames C. McPherson 2827c478bd9Sstevel@tonic-gate# 2837c478bd9Sstevel@tonic-gate# Enable or disable mpxio as specified by the cmd. 2847c478bd9Sstevel@tonic-gate# Returns 0 on success, 1 on failure. 2857c478bd9Sstevel@tonic-gate# 28660fffc19Sjw149990# Args: $cmd = {enable | disable} 28760fffc19Sjw149990# $d = {fp | mpt} 28860fffc19Sjw149990# 28960fffc19Sjw149990# the global variable $DRVLIST is used 29060fffc19Sjw149990# 2917c478bd9Sstevel@tonic-gateconfigure_mpxio() 2927c478bd9Sstevel@tonic-gate{ 293*a0261a43SJames C. McPherson # be careful here, we've got embedded \t characters 294*a0261a43SJames C. McPherson # in sed's pattern space. 2955a4c37c9Sqh201292 mpxiodisableno='mpxio-disable[ ]*=[ ]*"no"[ ]*;' 2965a4c37c9Sqh201292 mpxiodisableyes='mpxio-disable[ ]*=[ ]*"yes"[ ]*;' 2975a4c37c9Sqh201292 2987c478bd9Sstevel@tonic-gate if [ "x$cmd" = xenable ]; then 2995a4c37c9Sqh201292 mpxiodisable_cur_entry=$mpxiodisableyes 3007c478bd9Sstevel@tonic-gate propval=no 30160fffc19Sjw149990 msg=`gettext "STMS already enabled"` 3027c478bd9Sstevel@tonic-gate else 3035a4c37c9Sqh201292 mpxiodisable_cur_entry=$mpxiodisableno 3047c478bd9Sstevel@tonic-gate propval=yes 30560fffc19Sjw149990 msg=`gettext "STMS already disabled"` 3067c478bd9Sstevel@tonic-gate fi 3077c478bd9Sstevel@tonic-gate 30860fffc19Sjw149990 DRVCONF=$d.conf 30960fffc19Sjw149990 KDRVCONF=/kernel/drv/$d.conf 31060fffc19Sjw149990 TMPDRVCONF=/var/run/tmp.$d.conf.$$ 31160fffc19Sjw149990 TMPDRVCONF_MPXIO_ENTRY=/var/run/tmp.$d.conf.mpxioentry.$$; 31260fffc19Sjw149990 31360fffc19Sjw149990 if delete_mpxio_disable_entries $KDRVCONF $TMPDRVCONF $TMPDRVCONF_MPXIO_ENTRY; then 31460fffc19Sjw149990 31560fffc19Sjw149990 if [ -s $TMPDRVCONF_MPXIO_ENTRY ]; then 31660fffc19Sjw149990 # $DRVCONF does have mpxiodisable entries 31760fffc19Sjw149990 $EGREP -s "$mpxiodisable_cur_entry" $TMPDRVCONF_MPXIO_ENTRY 3185a4c37c9Sqh201292 if [ $? -ne 0 ]; then 3195a4c37c9Sqh201292 # if all mpxiodisable entries are no/yes for 3205a4c37c9Sqh201292 # enable/disable mpxio, notify the user 321*a0261a43SJames C. McPherson $RM -f $TMPDRVCONF $TMPDRVCONF_MPXIO_ENTRY > /dev/null 2>&1 32260fffc19Sjw149990 continue; 32360fffc19Sjw149990 else 32460fffc19Sjw149990 reboot_needed=`$EXPR $reboot_needed + 1` 3257c478bd9Sstevel@tonic-gate fi 32660fffc19Sjw149990 32760fffc19Sjw149990 # If mpxiodisable entries do not exist, always continue update 3285a4c37c9Sqh201292 fi 3297c478bd9Sstevel@tonic-gate else 330*a0261a43SJames C. McPherson $RM -f $TMPDRVCONF $TMPDRVCONF_MPXIO_ENTRY > /dev/null 2>&1 3317c478bd9Sstevel@tonic-gate gettext "failed to update " 1>&2 33260fffc19Sjw149990 echo "$KDRVCONF." 1>&2 3337c478bd9Sstevel@tonic-gate gettext "No changes were made to your STMS configuration.\n" 1>&2 3347c478bd9Sstevel@tonic-gate return 1 3357c478bd9Sstevel@tonic-gate fi 3365a4c37c9Sqh201292 33760fffc19Sjw149990 rm $TMPDRVCONF_MPXIO_ENTRY > /dev/null 2>&1 33860fffc19Sjw149990 echo "mpxio-disable=\"${propval}\";" >> $TMPDRVCONF 3395a4c37c9Sqh201292 3407c478bd9Sstevel@tonic-gate} 3417c478bd9Sstevel@tonic-gate 3427c478bd9Sstevel@tonic-gatesetcmd() 3437c478bd9Sstevel@tonic-gate{ 3447c478bd9Sstevel@tonic-gate if [ "x$cmd" = xnone ]; then 3457c478bd9Sstevel@tonic-gate cmd=$1 3467c478bd9Sstevel@tonic-gate else 3477c478bd9Sstevel@tonic-gate echo "$USAGE" 1>&2 3487c478bd9Sstevel@tonic-gate exit 2 3497c478bd9Sstevel@tonic-gate fi 3507c478bd9Sstevel@tonic-gate} 3517c478bd9Sstevel@tonic-gate 35260fffc19Sjw149990# 3535a4c37c9Sqh201292# Need to update bootpath on x86 if boot system from FC disk 3545a4c37c9Sqh201292# Only update bootpath here when mpxio is enabled 355*a0261a43SJames C. McPherson# If mpxio is currently disabled, then we'll update bootpath in the 356*a0261a43SJames C. McPherson# mpxio-upgrade service method on reboot. 35760fffc19Sjw149990# 35860fffc19Sjw149990 3595a4c37c9Sqh201292get_newbootpath_for_stmsdev() { 3605a4c37c9Sqh201292 if [ "x$cmd" = "xenable" ]; then 3615a4c37c9Sqh201292 return 0 3625a4c37c9Sqh201292 fi 3635a4c37c9Sqh201292 364*a0261a43SJames C. McPherson cur_bootpath=`$STMSBOOTUTIL -b` 365*a0261a43SJames C. McPherson if [ $? != 0 ]; then 3665a4c37c9Sqh201292 return 1 3675a4c37c9Sqh201292 fi 3685a4c37c9Sqh201292 369*a0261a43SJames C. McPherson # Since on x64 platforms the eeprom command doesn't update the 370*a0261a43SJames C. McPherson # kernel, the file /boot/solaris/bootenv.rc and the kernel's 371*a0261a43SJames C. McPherson # bootpath variable have a good chance of differing. We do some 372*a0261a43SJames C. McPherson # extra handwaving to get the correct bootpath variable setting. 373*a0261a43SJames C. McPherson 374*a0261a43SJames C. McPherson ONDISKVER=`$AWK '/bootpath/ {print $3}' /boot/solaris/bootenv.rc|\ 375*a0261a43SJames C. McPherson $SED -e"s,',,g"` 376*a0261a43SJames C. McPherson if [ "x$ONDISKVER" != "x$cur_bootpath" ]; then 377*a0261a43SJames C. McPherson cur_bootpath="$ONDISKVER" 378*a0261a43SJames C. McPherson fi 379*a0261a43SJames C. McPherson 380*a0261a43SJames C. McPherson NEWBOOTPATH="" 381*a0261a43SJames C. McPherson for path in $cur_bootpath; do 382*a0261a43SJames C. McPherson mapped=`$STMSBOOTUTIL -p $path` 383*a0261a43SJames C. McPherson if [ "$mapped" != "NOT_MAPPED" ]; then 384*a0261a43SJames C. McPherson if [ "$mapped" != "$path" ]; then 385*a0261a43SJames C. McPherson NEWBOOTPATH=`echo "$path " | \ 386*a0261a43SJames C. McPherson $SED -e"s|$path|$mapped|"`" $NEWBOOTPATH" 387*a0261a43SJames C. McPherson else 388*a0261a43SJames C. McPherson NEWBOOTPATH="$NEWBOOTPATH $path" 389*a0261a43SJames C. McPherson fi 390*a0261a43SJames C. McPherson fi 391*a0261a43SJames C. McPherson done 392*a0261a43SJames C. McPherson # now strip off leading and trailing space chars 393*a0261a43SJames C. McPherson new_bootpath=`echo $NEWBOOTPATH` 3945a4c37c9Sqh201292 return 0 39560fffc19Sjw149990} 39660fffc19Sjw149990 39760fffc19Sjw149990# 39860fffc19Sjw149990# Emit a warning message to the user that by default we 39960fffc19Sjw149990# operate on all multipath-capable controllers that are 40060fffc19Sjw149990# attached to the system, and that if they want to operate 40160fffc19Sjw149990# on only a specific controller type (fp|mpt|....) then 40260fffc19Sjw149990# they need to re-invoke stmsboot with "-D $driver" in 40360fffc19Sjw149990# their argument list 40460fffc19Sjw149990# 40560fffc19Sjw149990 40660fffc19Sjw149990emit_driver_warning_msg() { 40760fffc19Sjw149990 40860fffc19Sjw149990 # for each driver that we support, grab the list 40960fffc19Sjw149990 # of controllers attached to the system. 41060fffc19Sjw149990 411815dd917Sjmcp echo "" 41253ed03b5Sjmcp gettext "WARNING: stmsboot operates on each supported multipath-capable controller\n" 41353ed03b5Sjmcp gettext " detected in a host. In your system, these controllers are\n\n" 41460fffc19Sjw149990 415815dd917Sjmcp for WARNDRV in `echo $SUPPORTED_DRIVERS| $SED -e"s,|, ,g"`; do 416*a0261a43SJames C. McPherson $STMSBOOTUTIL -D $WARNDRV -n 41760fffc19Sjw149990 done; 41860fffc19Sjw149990 41960fffc19Sjw149990 echo "" 42053ed03b5Sjmcp gettext "If you do NOT wish to operate on these controllers, please quit stmsboot\n" 42153ed03b5Sjmcp gettext "and re-invoke with -D { fp | mpt } to specify which controllers you wish\n" 42253ed03b5Sjmcp gettext "to modify your multipathing configuration for.\n" 42360fffc19Sjw149990 424815dd917Sjmcp echo "" 42553ed03b5Sjmcp gettext "Do you wish to continue? [y/n] (default: y) " 42660fffc19Sjw149990 read response 42760fffc19Sjw149990 4288cecff49Sgp87344 if [ "x$response" != "x" -a "x$response" != "xY" -a \ 4298cecff49Sgp87344 "x$response" != "xy" ]; then 43060fffc19Sjw149990 exit 43160fffc19Sjw149990 fi 43260fffc19Sjw149990} 43360fffc19Sjw149990 4347c478bd9Sstevel@tonic-gate 435*a0261a43SJames C. McPherson# 436*a0261a43SJames C. McPherson# 437*a0261a43SJames C. McPherson# main starts here 438*a0261a43SJames C. McPherson# 439*a0261a43SJames C. McPherson 440*a0261a43SJames C. McPhersoncmd=none 4417c478bd9Sstevel@tonic-gate# process options 44260fffc19Sjw149990while getopts D:geduLl: c 4437c478bd9Sstevel@tonic-gatedo 4447c478bd9Sstevel@tonic-gate case $c in 4457c478bd9Sstevel@tonic-gate e) setcmd enable;; 4467c478bd9Sstevel@tonic-gate d) setcmd disable;; 4477c478bd9Sstevel@tonic-gate u) setcmd update;; 4487c478bd9Sstevel@tonic-gate L) setcmd listall;; 4497c478bd9Sstevel@tonic-gate l) setcmd list 4507c478bd9Sstevel@tonic-gate controller=$OPTARG;; 45160fffc19Sjw149990 D) DRV=$OPTARG;; 45260fffc19Sjw149990 g) GUID="-g";; 4537c478bd9Sstevel@tonic-gate \?) echo "$USAGE" 1>&2 4547c478bd9Sstevel@tonic-gate exit 2;; 4557c478bd9Sstevel@tonic-gate esac 4567c478bd9Sstevel@tonic-gatedone 4577c478bd9Sstevel@tonic-gate 4587c478bd9Sstevel@tonic-gateif [ "x$cmd" = xnone ]; then 4597c478bd9Sstevel@tonic-gate echo "$USAGE" 1>&2 4607c478bd9Sstevel@tonic-gate exit 2 4617c478bd9Sstevel@tonic-gatefi 4627c478bd9Sstevel@tonic-gate 46360fffc19Sjw149990if [ "x$DRV" = "x" ]; then 46460fffc19Sjw149990 DRVLIST="fp mpt" 46560fffc19Sjw149990else 46660fffc19Sjw149990 DRVLIST=$DRV 46760fffc19Sjw149990fi 46860fffc19Sjw149990 46934c94816SjmcpUSERID=`id | $EGREP "uid=0"` 47034c94816Sjmcpif [ -z "$USERID" ]; then 4717c478bd9Sstevel@tonic-gate gettext "You must be super-user to run this script.\n" 1>&2 4727c478bd9Sstevel@tonic-gate exit 1 4737c478bd9Sstevel@tonic-gatefi 4747c478bd9Sstevel@tonic-gate 4757c478bd9Sstevel@tonic-gate# just a sanity check 4767c478bd9Sstevel@tonic-gateif [ ! -f $STMSBOOTUTIL -o ! -f $STMSMETHODSCRIPT ]; then 4777c478bd9Sstevel@tonic-gate fmt=`gettext "Can't find %s and/or %s"` 4787c478bd9Sstevel@tonic-gate printf "$fmt\n" "$STMSBOOTUTIL" "$STMSMETHODSCRIPT" 1>&2 4797c478bd9Sstevel@tonic-gate exit 1 4807c478bd9Sstevel@tonic-gatefi 4817c478bd9Sstevel@tonic-gate 48260fffc19Sjw149990# If the old sun4u-specific SMF method is found, remove it 483815dd917Sjmcp$SVCCFG -s "platform/sun4u/mpxio-upgrade:default" < /dev/null > /dev/null 2>&1 484815dd917Sjmcpif [ $? -eq 0 ]; then 485815dd917Sjmcp $SVCCFG delete "platform/sun4u/mpxio-upgrade:default" > /dev/null 2>&1 48660fffc19Sjw149990fi 48760fffc19Sjw149990 48860fffc19Sjw149990# now import the new service, if necessary 489815dd917Sjmcp$SVCPROP -q $STMSINSTANCE < /dev/null > /dev/null 2>&1 49060fffc19Sjw149990if [ $? -ne 0 ]; then 49160fffc19Sjw149990 if [ -f /var/svc/manifest/system/device/mpxio-upgrade.xml ]; then 492815dd917Sjmcp $SVCCFG import /var/svc/manifest/system/device/mpxio-upgrade.xml 49360fffc19Sjw149990 if [ $? -ne 0 ]; then 49453ed03b5Sjmcp fmt=`gettext "Unable to import the %s service"` 4957c478bd9Sstevel@tonic-gate printf "$fmt\n" "$STMSINSTANCE" 1>&2 4967c478bd9Sstevel@tonic-gate exit 1 49760fffc19Sjw149990 else 49860fffc19Sjw149990 fmt=`gettext "Service %s imported successfully, continuing"` 49960fffc19Sjw149990 printf "$fmt\n" "$STMSINSTANCE" 1>&2 50060fffc19Sjw149990 fi 50160fffc19Sjw149990 else 50260fffc19Sjw149990 fmt=`gettext "Service %s does not exist on this host"` 50360fffc19Sjw149990 printf "$fmt\n" "$STMSINSTANCE" 1>&2 50460fffc19Sjw149990 exit 1 50560fffc19Sjw149990 fi 5067c478bd9Sstevel@tonic-gatefi 5077c478bd9Sstevel@tonic-gate 508*a0261a43SJames C. McPherson 509*a0261a43SJames C. McPherson# make sure we can stash our data somewhere private 510*a0261a43SJames C. McPhersonif [ ! -d $SAVEDIR ]; then 511*a0261a43SJames C. McPherson $MKDIR -p $SAVEDIR 512*a0261a43SJames C. McPhersonfi 513*a0261a43SJames C. McPherson# prime the cache 514*a0261a43SJames C. McPherson$STMSBOOTUTIL -i 515*a0261a43SJames C. McPherson 516*a0261a43SJames C. McPherson 5177c478bd9Sstevel@tonic-gateif [ "x$cmd" = xenable -o "x$cmd" = xdisable -o "x$cmd" = xupdate ]; then 5187c478bd9Sstevel@tonic-gate # 5197c478bd9Sstevel@tonic-gate # The bootup script doesn't work on cache-only-clients as the script 5206deb031bSsjelinek # is executed before the plumbing for cachefs mounting of root is done. 5217c478bd9Sstevel@tonic-gate # 52260fffc19Sjw149990 if $MOUNT -v | $EGREP -s " on / type (nfs|cachefs) "; then 523*a0261a43SJames C. McPherson gettext "This command option is not supported on systems with an nfs or cachefs mounted root filesystem.\n" 1>&2 5247c478bd9Sstevel@tonic-gate exit 1 5257c478bd9Sstevel@tonic-gate fi 5267c478bd9Sstevel@tonic-gate 527815dd917Sjmcp # if the user has left the system with the mpxio-upgrade service 528815dd917Sjmcp # in a temporarily disabled state (ie, service is armed for the next 529815dd917Sjmcp # reboot), then let them know. We need to ensure that the system is 530815dd917Sjmcp # is in a sane state before allowing any further invocations, so 531815dd917Sjmcp # try to get the system admin to do so 532815dd917Sjmcp 533*a0261a43SJames C. McPherson ISARMED=`$SVCS -l $STMSINSTANCE|$GREP "enabled.*false.*temporary"` 534*a0261a43SJames C. McPherson if [ ! $? ]; then 535815dd917Sjmcp echo "" 53653ed03b5Sjmcp gettext "You need to reboot the system in order to complete\n" 53753ed03b5Sjmcp gettext "the previous invocation of stmsboot.\n" 538815dd917Sjmcp echo "" 53953ed03b5Sjmcp gettext "Do you wish to reboot the system now? (y/n, default y) " 540815dd917Sjmcp read response 541815dd917Sjmcp 5428cecff49Sgp87344 if [ "x$response" = "x" -o "x$response" = "xY" -o \ 5438cecff49Sgp87344 "x$response" = "xy" ]; then 544*a0261a43SJames C. McPherson $REBOOT 545815dd917Sjmcp else 54653ed03b5Sjmcp echo "" 54753ed03b5Sjmcp gettext "Please reboot this system before continuing\n" 54853ed03b5Sjmcp echo "" 549815dd917Sjmcp exit 1 550815dd917Sjmcp fi 551815dd917Sjmcp fi 552815dd917Sjmcp 5537c478bd9Sstevel@tonic-gate # 5547c478bd9Sstevel@tonic-gate # keep a copy of the last saved files, useful for manual 5557c478bd9Sstevel@tonic-gate # recovery in case of a problem. 5567c478bd9Sstevel@tonic-gate # 55760fffc19Sjw149990 for d in $DRVLIST; do 55860fffc19Sjw149990 DRVCONF=$d.conf 55960fffc19Sjw149990 KDRVCONF=/kernel/drv/$d.conf 56060fffc19Sjw149990 TMPDRVCONF=/var/run/tmp.$d.conf.$$ 56160fffc19Sjw149990 TMPDRVCONF_MPXIO_ENTRY=/var/run/tmp.$d.conf.mpxioentry.$$; 5625a4c37c9Sqh201292 if [ "x$MACH" = "xsparc" ]; then 56360fffc19Sjw149990 backup_lastsaved $KDRVCONF $VFSTAB 5647c478bd9Sstevel@tonic-gate else 565*a0261a43SJames C. McPherson backup_lastsaved $KDRVCONF $VFSTAB /boot/solaris/$BOOTENV_FILE 5665a4c37c9Sqh201292 fi 56760fffc19Sjw149990 done 5687c478bd9Sstevel@tonic-gatefi 5697c478bd9Sstevel@tonic-gate 5707c478bd9Sstevel@tonic-gateif [ "x$cmd" = xenable -o "x$cmd" = xdisable ]; then 57160fffc19Sjw149990 57260fffc19Sjw149990 msgneeded=`echo "$DRVLIST" |grep " "` 57360fffc19Sjw149990 if [ -n "$msgneeded" ]; then 57460fffc19Sjw149990 emit_driver_warning_msg 57560fffc19Sjw149990 fi 57660fffc19Sjw149990 for d in $DRVLIST; do 57760fffc19Sjw149990 configure_mpxio $cmd $d 57860fffc19Sjw149990 done 57960fffc19Sjw149990 58060fffc19Sjw149990 if [ $reboot_needed -ne 0 ]; then 58160fffc19Sjw149990 # Need to update bootpath on x86 if our boot device is 58260fffc19Sjw149990 # now accessed through mpxio. 58360fffc19Sjw149990 # Only update bootpath before reboot when mpxio is enabled 58460fffc19Sjw149990 # If mpxio is currently disabled, we will update bootpath 58560fffc19Sjw149990 # on reboot in the mpxio-upgrade service 58660fffc19Sjw149990 58760fffc19Sjw149990 if [ "x$MACH" = "xi386" -a "x$cmd" = "xdisable" ]; then 58860fffc19Sjw149990 get_newbootpath_for_stmsdev 58960fffc19Sjw149990 if [ $? -ne 0 ]; then 590*a0261a43SJames C. McPherson $RM -f $TMPDRVCONF > /dev/null 2>&1 59160fffc19Sjw149990 gettext "failed to update bootpath.\n" 1>&2 59260fffc19Sjw149990 gettext "No changes were made to your STMS configuration.\n" 1>&2 59360fffc19Sjw149990 return 1 59460fffc19Sjw149990 fi 59560fffc19Sjw149990 fi 59660fffc19Sjw149990 update_sysfiles 59760fffc19Sjw149990 else 59860fffc19Sjw149990 echo "STMS is already ${cmd}d. No changes or reboots needed" 59960fffc19Sjw149990 fi 60060fffc19Sjw149990 60160fffc19Sjw149990 6027c478bd9Sstevel@tonic-gateelif [ "x$cmd" = xupdate ]; then 6035a4c37c9Sqh201292 if [ "x$MACH" = "xi386" ]; then 6045a4c37c9Sqh201292 # In this case we always change the bootpath to phci-based 6055a4c37c9Sqh201292 # path first. bootpath will later be modified in mpxio-upgrade 6065a4c37c9Sqh201292 # to the vhci-based path if mpxio is enabled on root. 6075a4c37c9Sqh201292 get_newbootpath_for_stmsdev 6085a4c37c9Sqh201292 if [ $? -ne 0 ]; then 6095a4c37c9Sqh201292 gettext "failed to update bootpath.\n" 1>&2 6105a4c37c9Sqh201292 return 1 6115a4c37c9Sqh201292 fi 6125a4c37c9Sqh201292 fi 6137c478bd9Sstevel@tonic-gate update_sysfiles 61460fffc19Sjw149990 6157c478bd9Sstevel@tonic-gateelif [ "x$cmd" = xlist ]; then 61660fffc19Sjw149990 $STMSBOOTUTIL $GUID -l $controller 6177c478bd9Sstevel@tonic-gateelse 61860fffc19Sjw149990 $STMSBOOTUTIL $GUID -L 6197c478bd9Sstevel@tonic-gatefi 6207c478bd9Sstevel@tonic-gate 6217c478bd9Sstevel@tonic-gateexit $? 622