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# 23*5a4c37c9Sqh201292# 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 317c478bd9Sstevel@tonic-gateFPCONF=/kernel/drv/fp.conf 327c478bd9Sstevel@tonic-gateTMPFPCONF=/var/run/tmp.fp.conf.$$ 33*5a4c37c9Sqh201292TMPFPCONF_MPXIO_ENTRY=/var/run/tmp.fp.conf.mpxioentry.$$ 347c478bd9Sstevel@tonic-gateVFSTAB=/etc/vfstab 357c478bd9Sstevel@tonic-gateSAVEDIR=/etc/mpxio 367c478bd9Sstevel@tonic-gateRECOVERFILE=$SAVEDIR/recover_instructions 377c478bd9Sstevel@tonic-gateSVCCFG_RECOVERY=$SAVEDIR/svccfg_recover 387c478bd9Sstevel@tonic-gateUSAGE=`gettext "Usage: stmsboot -e | -d | -u | -L | -l controller_number"` 39aca6e9ccSramatTEXTDOMAIN=SUNW_OST_OSCMD 40aca6e9ccSramatexport TEXTDOMAIN 41*5a4c37c9Sqh201292STMSINSTANCE=system/device/mpxio-upgrade:default 427c478bd9Sstevel@tonic-gate 43*5a4c37c9Sqh201292MACH=`/usr/bin/uname -p` 44*5a4c37c9Sqh201292if [ "x$MACH" = "xsparc" ]; then 45*5a4c37c9Sqh201292 CLIENT_TYPE_VHCI="/scsi_vhci.*/ssd@.*" 46*5a4c37c9Sqh201292 CLIENT_TYPE_PHCI="/fp@.*/ssd@.*" 47*5a4c37c9Sqh201292else 48*5a4c37c9Sqh201292 CLIENT_TYPE_VHCI="/scsi_vhci.*/disk@.*" 49*5a4c37c9Sqh201292 CLIENT_TYPE_PHCI="/fp@.*/disk@.*" 50*5a4c37c9Sqh201292 BOOTENV_FILE=/boot/solaris/bootenv.rc 51*5a4c37c9Sqh201292fi 527c478bd9Sstevel@tonic-gate# 537c478bd9Sstevel@tonic-gate# Copy all entries (including comments) from source driver.conf to destination 547c478bd9Sstevel@tonic-gate# driver.conf except those entries which contain mpxio-disable property. 557c478bd9Sstevel@tonic-gate# Take into consideration entries that spawn more than one line. 567c478bd9Sstevel@tonic-gate# 577c478bd9Sstevel@tonic-gate# $1 source driver.conf file 587c478bd9Sstevel@tonic-gate# $2 destination driver.conf file 597c478bd9Sstevel@tonic-gate# 607c478bd9Sstevel@tonic-gate# Returns 0 on success, non zero on failure. 617c478bd9Sstevel@tonic-gate# 627c478bd9Sstevel@tonic-gatedelete_mpxio_disable_entries() 637c478bd9Sstevel@tonic-gate{ 647c478bd9Sstevel@tonic-gate sed ' 657c478bd9Sstevel@tonic-gate /^[ ]*#/{ p 667c478bd9Sstevel@tonic-gate d 677c478bd9Sstevel@tonic-gate } 687c478bd9Sstevel@tonic-gate s/[ ]*$// 697c478bd9Sstevel@tonic-gate /^$/{ p 707c478bd9Sstevel@tonic-gate d 717c478bd9Sstevel@tonic-gate } 72*5a4c37c9Sqh201292 /mpxio-disable[ ]*=.*;$/{ w '$3' 73*5a4c37c9Sqh201292 d 74*5a4c37c9Sqh201292 } 757c478bd9Sstevel@tonic-gate /;$/{ p 767c478bd9Sstevel@tonic-gate d 777c478bd9Sstevel@tonic-gate } 787c478bd9Sstevel@tonic-gate :rdnext 797c478bd9Sstevel@tonic-gate N 807c478bd9Sstevel@tonic-gate s/[ ]*$// 817c478bd9Sstevel@tonic-gate /[^;]$/b rdnext 82*5a4c37c9Sqh201292 /mpxio-disable[ ]*=/{ s/\n/ /g 83*5a4c37c9Sqh201292 w '$3' 84*5a4c37c9Sqh201292 d 85*5a4c37c9Sqh201292 } 86*5a4c37c9Sqh201292 ' $1 > $2 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate return $? 897c478bd9Sstevel@tonic-gate} 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate# 927c478bd9Sstevel@tonic-gate# backup the last saved copy of the specified files. 937c478bd9Sstevel@tonic-gate# $* files to backup 947c478bd9Sstevel@tonic-gate# 957c478bd9Sstevel@tonic-gatebackup_lastsaved() 967c478bd9Sstevel@tonic-gate{ 977c478bd9Sstevel@tonic-gate for file in $* 987c478bd9Sstevel@tonic-gate do 997c478bd9Sstevel@tonic-gate file=`basename $file` 1007c478bd9Sstevel@tonic-gate if [ -f $SAVEDIR/$file ]; then 1017c478bd9Sstevel@tonic-gate mv $SAVEDIR/$file $SAVEDIR/${file}.old 1027c478bd9Sstevel@tonic-gate fi 1037c478bd9Sstevel@tonic-gate done 1047c478bd9Sstevel@tonic-gate} 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate# 1077c478bd9Sstevel@tonic-gate# build recover instructions 1087c478bd9Sstevel@tonic-gate# 1097c478bd9Sstevel@tonic-gate# $1 1 to include boot script in the instructions 1107c478bd9Sstevel@tonic-gate# 0 otherwise 1117c478bd9Sstevel@tonic-gate# 1127c478bd9Sstevel@tonic-gatebuild_recover() 1137c478bd9Sstevel@tonic-gate{ 1147c478bd9Sstevel@tonic-gate gettext "Instructions to recover your previous STMS configuration (if in case the system does not boot):\n\n" > $RECOVERFILE 1157c478bd9Sstevel@tonic-gate echo "\tboot net \c" >> $RECOVERFILE 1167c478bd9Sstevel@tonic-gate gettext "(or from a cd/dvd/another disk)\n" >> $RECOVERFILE 1177c478bd9Sstevel@tonic-gate echo "\tfsck <your-root-device>" >> $RECOVERFILE 1187c478bd9Sstevel@tonic-gate echo "\tmount <your-root-device> /mnt" >> $RECOVERFILE 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate if [ "x$cmd" = xupdate ]; then 1217c478bd9Sstevel@tonic-gate gettext "\tUndo the modifications you made to STMS configuration.\n\tFor example undo any changes you made to " >> $RECOVERFILE 1227c478bd9Sstevel@tonic-gate echo "/mnt$FPCONF." >> $RECOVERFILE 1237c478bd9Sstevel@tonic-gate else 1247c478bd9Sstevel@tonic-gate echo "\tcp /mnt${SAVEDIR}/fp.conf /mnt$FPCONF" >> $RECOVERFILE 1257c478bd9Sstevel@tonic-gate fi 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate if [ $1 -eq 1 ]; then 1287c478bd9Sstevel@tonic-gate echo "\tcp /mnt${SAVEDIR}/vfstab /mnt$VFSTAB" >> $RECOVERFILE 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate echo "repository /mnt/etc/svc/repository.db" > $SVCCFG_RECOVERY 1317c478bd9Sstevel@tonic-gate echo "select $STMSINSTANCE" >> $SVCCFG_RECOVERY 1327c478bd9Sstevel@tonic-gate echo "setprop general/enabled=false" >> $SVCCFG_RECOVERY 1337c478bd9Sstevel@tonic-gate echo "exit" >> $SVCCFG_RECOVERY 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate echo "\t/usr/sbin/svccfg -f /mnt$SVCCFG_RECOVERY" >> $RECOVERFILE 136*5a4c37c9Sqh201292 137*5a4c37c9Sqh201292 if [ "x$MACH" = "xi386" -a "x$new_bootpath" != "x" ]; then 138*5a4c37c9Sqh201292 echo "\tcp /mnt${SAVEDIR}/bootenv.rc /mnt$BOOTENV_FILE" >> $RECOVERFILE 139*5a4c37c9Sqh201292 fi 1407c478bd9Sstevel@tonic-gate fi 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate rootdisk=`mount | grep "/ on " | cut -f 3 -d " "` 1437c478bd9Sstevel@tonic-gate echo "\tumount /mnt\n\treboot\n\n${rootdisk} \c" >> $RECOVERFILE 1447c478bd9Sstevel@tonic-gate gettext "was your root device,\nbut it could be named differently after you boot net.\n" >> $RECOVERFILE 1457c478bd9Sstevel@tonic-gate} 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate# 1487c478bd9Sstevel@tonic-gate# Arrange for /etc/vfstab and dump configuration to be updated 1497c478bd9Sstevel@tonic-gate# during the next reboot. If the cmd is "enable" or "disable", copy 1507c478bd9Sstevel@tonic-gate# $TMPFPCONF to $FPCONF. 1517c478bd9Sstevel@tonic-gate# 1527c478bd9Sstevel@tonic-gate# Returns 0 on success, 1 on failure. 1537c478bd9Sstevel@tonic-gate# 1547c478bd9Sstevel@tonic-gateupdate_sysfiles() 1557c478bd9Sstevel@tonic-gate{ 1567c478bd9Sstevel@tonic-gate gettext "WARNING: This operation will require a reboot.\nDo you want to continue ? [y/n] (default: y) " 1577c478bd9Sstevel@tonic-gate read response 1587c478bd9Sstevel@tonic-gate 1597c478bd9Sstevel@tonic-gate if [ "x$response" != x -a "x$response" != xy -a \ 1607c478bd9Sstevel@tonic-gate "x$response" != xY ]; then 1617c478bd9Sstevel@tonic-gate rm -f $TMPFPCONF 1627c478bd9Sstevel@tonic-gate return 0 1637c478bd9Sstevel@tonic-gate fi 1647c478bd9Sstevel@tonic-gate 1657c478bd9Sstevel@tonic-gate need_bootscript=1 1667c478bd9Sstevel@tonic-gate if [ "x$cmd" = xenable -o "x$cmd" = xdisable ]; then 1677c478bd9Sstevel@tonic-gate cp $FPCONF $SAVEDIR 1687c478bd9Sstevel@tonic-gate cp $TMPFPCONF $FPCONF 1697c478bd9Sstevel@tonic-gate rm -f $TMPFPCONF 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate # 1727c478bd9Sstevel@tonic-gate # there is no need to update the system files in the following 1737c478bd9Sstevel@tonic-gate # cases: 1747c478bd9Sstevel@tonic-gate # - we are enabling mpxio and the system has no configured 1757c478bd9Sstevel@tonic-gate # disks accessible by phci paths. 1767c478bd9Sstevel@tonic-gate # - we are disabling mpxio and the system has no configured 1777c478bd9Sstevel@tonic-gate # disks accessible by vhci paths. 1787c478bd9Sstevel@tonic-gate # 1797c478bd9Sstevel@tonic-gate if [ "x$cmd" = xenable ]; then 1807c478bd9Sstevel@tonic-gate ls -l /dev/dsk/*s2 2> /dev/null | \ 181*5a4c37c9Sqh201292 egrep -s $CLIENT_TYPE_PHCI 1827c478bd9Sstevel@tonic-gate else 1837c478bd9Sstevel@tonic-gate ls -l /dev/dsk/*s2 2> /dev/null | \ 184*5a4c37c9Sqh201292 egrep -s $CLIENT_TYPE_VHCI 1857c478bd9Sstevel@tonic-gate fi 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate if [ $? -ne 0 ]; then 1887c478bd9Sstevel@tonic-gate need_bootscript=0 1897c478bd9Sstevel@tonic-gate fi 1907c478bd9Sstevel@tonic-gate fi 1917c478bd9Sstevel@tonic-gate 1927c478bd9Sstevel@tonic-gate if [ $need_bootscript -eq 1 ]; then 193*5a4c37c9Sqh201292 if [ "x$MACH" = "xi386" -a "x$new_bootpath" != "x" ]; then 194*5a4c37c9Sqh201292 #only update bootpath for x86. 195*5a4c37c9Sqh201292 cp $BOOTENV_FILE $SAVEDIR 196*5a4c37c9Sqh201292 eeprom bootpath=$new_bootpath 197*5a4c37c9Sqh201292 fi 1987c478bd9Sstevel@tonic-gate # 1997c478bd9Sstevel@tonic-gate # Enable the mpxio-upgrade service, but don't run it now. 2007c478bd9Sstevel@tonic-gate # The service will run during the next reboot and will do 2017c478bd9Sstevel@tonic-gate # the actual job of modifying the system files. 2027c478bd9Sstevel@tonic-gate # 2037c478bd9Sstevel@tonic-gate svcadm disable -t $STMSINSTANCE 2047c478bd9Sstevel@tonic-gate svccfg -f - << EOF 2057c478bd9Sstevel@tonic-gateselect $STMSINSTANCE 2067c478bd9Sstevel@tonic-gatesetprop general/enabled = true 2077c478bd9Sstevel@tonic-gateEOF 2087c478bd9Sstevel@tonic-gate fi 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate build_recover $need_bootscript 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate gettext "The changes will come into effect after rebooting the system.\nReboot the system now ? [y/n] (default: y) " 2137c478bd9Sstevel@tonic-gate read response 2147c478bd9Sstevel@tonic-gate 2157c478bd9Sstevel@tonic-gate if [ "x$response" = x -o "x$response" = xy -o \ 2167c478bd9Sstevel@tonic-gate "x$response" = xY ]; then 2177c478bd9Sstevel@tonic-gate reboot 2187c478bd9Sstevel@tonic-gate fi 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate return 0 2217c478bd9Sstevel@tonic-gate} 2227c478bd9Sstevel@tonic-gate 2237c478bd9Sstevel@tonic-gate# 2247c478bd9Sstevel@tonic-gate# Enable or disable mpxio as specified by the cmd. 2257c478bd9Sstevel@tonic-gate# Returns 0 on success, 1 on failure. 2267c478bd9Sstevel@tonic-gate# 2277c478bd9Sstevel@tonic-gateconfigure_mpxio() 2287c478bd9Sstevel@tonic-gate{ 229*5a4c37c9Sqh201292 mpxiodisableno='mpxio-disable[ ]*=[ ]*"no"[ ]*;' 230*5a4c37c9Sqh201292 mpxiodisableyes='mpxio-disable[ ]*=[ ]*"yes"[ ]*;' 231*5a4c37c9Sqh201292 2327c478bd9Sstevel@tonic-gate if [ "x$cmd" = xenable ]; then 233*5a4c37c9Sqh201292 mpxiodisable_cur_entry=$mpxiodisableyes 2347c478bd9Sstevel@tonic-gate propval=no 2357c478bd9Sstevel@tonic-gate msg=`gettext "STMS already enabled."` 2367c478bd9Sstevel@tonic-gate else 237*5a4c37c9Sqh201292 mpxiodisable_cur_entry=$mpxiodisableno 2387c478bd9Sstevel@tonic-gate propval=yes 2397c478bd9Sstevel@tonic-gate msg=`gettext "STMS already disabled."` 2407c478bd9Sstevel@tonic-gate fi 2417c478bd9Sstevel@tonic-gate 242*5a4c37c9Sqh201292 if delete_mpxio_disable_entries $FPCONF $TMPFPCONF $TMPFPCONF_MPXIO_ENTRY; then 243*5a4c37c9Sqh201292 if [ -s $TMPFPCONF_MPXIO_ENTRY ]; then 244*5a4c37c9Sqh201292 # fp.conf does have mpxiodisable entries 245*5a4c37c9Sqh201292 egrep -s "$mpxiodisable_cur_entry" $TMPFPCONF_MPXIO_ENTRY 246*5a4c37c9Sqh201292 if [ $? -ne 0 ]; then 247*5a4c37c9Sqh201292 # if all mpxiodisable entries are no/yes for 248*5a4c37c9Sqh201292 # enable/disable mpxio, notify the user 249*5a4c37c9Sqh201292 rm -f $TMPFPCONF $TMPFPCONF_MPXIO_ENTRY 2507c478bd9Sstevel@tonic-gate echo "$msg" 2517c478bd9Sstevel@tonic-gate return 0 2527c478bd9Sstevel@tonic-gate fi 253*5a4c37c9Sqh201292 # If mpxiodisable entries does not exist, always continue update 254*5a4c37c9Sqh201292 fi 2557c478bd9Sstevel@tonic-gate else 256*5a4c37c9Sqh201292 rm -f $TMPFPCONF $TMPFPCONF_MPXIO_ENTRY 2577c478bd9Sstevel@tonic-gate gettext "failed to update " 1>&2 2587c478bd9Sstevel@tonic-gate echo "$FPCONF." 1>&2 2597c478bd9Sstevel@tonic-gate gettext "No changes were made to your STMS configuration.\n" 1>&2 2607c478bd9Sstevel@tonic-gate return 1 2617c478bd9Sstevel@tonic-gate fi 262*5a4c37c9Sqh201292 263*5a4c37c9Sqh201292 rm $TMPFPCONF_MPXIO_ENTRY 264*5a4c37c9Sqh201292 echo "mpxio-disable=\"${propval}\";" >> $TMPFPCONF 265*5a4c37c9Sqh201292 266*5a4c37c9Sqh201292 #Need to update bootpath on x86 if boot system from FC disk 267*5a4c37c9Sqh201292 #Only update bootpath before reboot when mpxio is enabled 268*5a4c37c9Sqh201292 #If mpxio is disabled currently, will update bootpath in mpxio-upgrade 269*5a4c37c9Sqh201292 if [ "x$MACH" = "xi386" -a "x$cmd" = "xdisable" ]; then 270*5a4c37c9Sqh201292 get_newbootpath_for_stmsdev 271*5a4c37c9Sqh201292 if [ $? -ne 0 ]; then 272*5a4c37c9Sqh201292 rm -f $TMPFPCONF 273*5a4c37c9Sqh201292 gettext "failed to update bootpath.\n" 1>&2 274*5a4c37c9Sqh201292 gettext "No changes were made to your STMS configuration.\n" 1>&2 275*5a4c37c9Sqh201292 return 1 276*5a4c37c9Sqh201292 fi 277*5a4c37c9Sqh201292 fi 278*5a4c37c9Sqh201292 update_sysfiles 279*5a4c37c9Sqh201292 return $? 2807c478bd9Sstevel@tonic-gate} 2817c478bd9Sstevel@tonic-gate 2827c478bd9Sstevel@tonic-gatesetcmd() 2837c478bd9Sstevel@tonic-gate{ 2847c478bd9Sstevel@tonic-gate if [ "x$cmd" = xnone ]; then 2857c478bd9Sstevel@tonic-gate cmd=$1 2867c478bd9Sstevel@tonic-gate else 2877c478bd9Sstevel@tonic-gate echo "$USAGE" 1>&2 2887c478bd9Sstevel@tonic-gate exit 2 2897c478bd9Sstevel@tonic-gate fi 2907c478bd9Sstevel@tonic-gate} 2917c478bd9Sstevel@tonic-gate 292*5a4c37c9Sqh201292 293*5a4c37c9Sqh201292#Need to update bootpath on x86 if boot system from FC disk 294*5a4c37c9Sqh201292#Only update bootpath here when mpxio is enabled 295*5a4c37c9Sqh201292#If mpxio is disabled currently, will update bootpath in mpxio-upgrade 296*5a4c37c9Sqh201292get_newbootpath_for_stmsdev() { 297*5a4c37c9Sqh201292 if [ "x$cmd" = "xenable" ]; then 298*5a4c37c9Sqh201292 return 0 299*5a4c37c9Sqh201292 fi 300*5a4c37c9Sqh201292 301*5a4c37c9Sqh201292 cur_bootpath=`eeprom bootpath | sed 's/bootpath=[ ]*//g' | sed 's/[ ]*$//'` 302*5a4c37c9Sqh201292 if [ "x$cur_bootpath" = "x" ]; then 303*5a4c37c9Sqh201292 gettext "failed to get bootpath by eeprom\n" 1>&2 304*5a4c37c9Sqh201292 return 1 305*5a4c37c9Sqh201292 fi 306*5a4c37c9Sqh201292 307*5a4c37c9Sqh201292 #only update bootpath for STMS path 308*5a4c37c9Sqh201292 echo $cur_bootpath|grep $CLIENT_TYPE_VHCI > /dev/null 2>&1 309*5a4c37c9Sqh201292 if [ $? -eq 1 ]; then 310*5a4c37c9Sqh201292 return 0 311*5a4c37c9Sqh201292 fi 312*5a4c37c9Sqh201292 313*5a4c37c9Sqh201292 new_bootpath=`$STMSBOOTUTIL -p /devices$cur_bootpath` 314*5a4c37c9Sqh201292 if [ $? -ne 0 ]; then 315*5a4c37c9Sqh201292 new_bootpath="" 316*5a4c37c9Sqh201292 return 1 317*5a4c37c9Sqh201292 fi 318*5a4c37c9Sqh201292} 319*5a4c37c9Sqh201292 320*5a4c37c9Sqh201292 3217c478bd9Sstevel@tonic-gatecmd=none 3227c478bd9Sstevel@tonic-gate 3237c478bd9Sstevel@tonic-gate# process options 3247c478bd9Sstevel@tonic-gatewhile getopts eduLl: c 3257c478bd9Sstevel@tonic-gatedo 3267c478bd9Sstevel@tonic-gate case $c in 3277c478bd9Sstevel@tonic-gate e) setcmd enable;; 3287c478bd9Sstevel@tonic-gate d) setcmd disable;; 3297c478bd9Sstevel@tonic-gate u) setcmd update;; 3307c478bd9Sstevel@tonic-gate L) setcmd listall;; 3317c478bd9Sstevel@tonic-gate l) setcmd list 3327c478bd9Sstevel@tonic-gate controller=$OPTARG;; 3337c478bd9Sstevel@tonic-gate \?) echo "$USAGE" 1>&2 3347c478bd9Sstevel@tonic-gate exit 2;; 3357c478bd9Sstevel@tonic-gate esac 3367c478bd9Sstevel@tonic-gatedone 3377c478bd9Sstevel@tonic-gate 3387c478bd9Sstevel@tonic-gateif [ "x$cmd" = xnone ]; then 3397c478bd9Sstevel@tonic-gate echo "$USAGE" 1>&2 3407c478bd9Sstevel@tonic-gate exit 2 3417c478bd9Sstevel@tonic-gatefi 3427c478bd9Sstevel@tonic-gate 3437c478bd9Sstevel@tonic-gateset `id` 3447c478bd9Sstevel@tonic-gateif [ "$1" != "uid=0(root)" ]; then 3457c478bd9Sstevel@tonic-gate gettext "You must be super-user to run this script.\n" 1>&2 3467c478bd9Sstevel@tonic-gate exit 1 3477c478bd9Sstevel@tonic-gatefi 3487c478bd9Sstevel@tonic-gate 3497c478bd9Sstevel@tonic-gate# just a sanity check 3507c478bd9Sstevel@tonic-gateif [ ! -f $STMSBOOTUTIL -o ! -f $STMSMETHODSCRIPT ]; then 3517c478bd9Sstevel@tonic-gate fmt=`gettext "Can't find %s and/or %s"` 3527c478bd9Sstevel@tonic-gate printf "$fmt\n" "$STMSBOOTUTIL" "$STMSMETHODSCRIPT" 1>&2 3537c478bd9Sstevel@tonic-gate exit 1 3547c478bd9Sstevel@tonic-gatefi 3557c478bd9Sstevel@tonic-gate 3567c478bd9Sstevel@tonic-gatesvcprop -q $STMSINSTANCE 3577c478bd9Sstevel@tonic-gateif [ $? -ne 0 ]; then 3587c478bd9Sstevel@tonic-gate fmt=`gettext "Can't find %s service"` 3597c478bd9Sstevel@tonic-gate printf "$fmt\n" "$STMSINSTANCE" 1>&2 3607c478bd9Sstevel@tonic-gate exit 1 3617c478bd9Sstevel@tonic-gatefi 3627c478bd9Sstevel@tonic-gate 3637c478bd9Sstevel@tonic-gateif [ "x$cmd" = xenable -o "x$cmd" = xdisable -o "x$cmd" = xupdate ]; then 3647c478bd9Sstevel@tonic-gate # 3657c478bd9Sstevel@tonic-gate # The bootup script doesn't work on cache-only-clients as the script 3666deb031bSsjelinek # is executed before the plumbing for cachefs mounting of root is done. 3677c478bd9Sstevel@tonic-gate # 3687c478bd9Sstevel@tonic-gate if mount -v | egrep -s " on / type (nfs|cachefs) "; then 3697c478bd9Sstevel@tonic-gate gettext "This command option is not supported on systems with nfs or cachefs mounted root filesystem.\n" 1>&2 3707c478bd9Sstevel@tonic-gate exit 1 3717c478bd9Sstevel@tonic-gate fi 3727c478bd9Sstevel@tonic-gate 3737c478bd9Sstevel@tonic-gate if [ -d $SAVEDIR ]; then 3747c478bd9Sstevel@tonic-gate # 3757c478bd9Sstevel@tonic-gate # keep a copy of the last saved files, useful for manual 3767c478bd9Sstevel@tonic-gate # recovery in case of a problem. 3777c478bd9Sstevel@tonic-gate # 378*5a4c37c9Sqh201292 if [ "x$MACH" = "xsparc" ]; then 3797c478bd9Sstevel@tonic-gate backup_lastsaved $FPCONF $VFSTAB 3807c478bd9Sstevel@tonic-gate else 381*5a4c37c9Sqh201292 backup_lastsaved $FPCONF $VFSTAB $BOOTENV_FILE 382*5a4c37c9Sqh201292 fi 383*5a4c37c9Sqh201292 else 3847c478bd9Sstevel@tonic-gate mkdir $SAVEDIR 3857c478bd9Sstevel@tonic-gate fi 3867c478bd9Sstevel@tonic-gate 3877c478bd9Sstevel@tonic-gatefi 3887c478bd9Sstevel@tonic-gate 3897c478bd9Sstevel@tonic-gateif [ "x$cmd" = xenable -o "x$cmd" = xdisable ]; then 3907c478bd9Sstevel@tonic-gate configure_mpxio $cmd 3917c478bd9Sstevel@tonic-gateelif [ "x$cmd" = xupdate ]; then 392*5a4c37c9Sqh201292 if [ "x$MACH" = "xi386" ]; then 393*5a4c37c9Sqh201292 # In this case we always change the bootpath to phci-based 394*5a4c37c9Sqh201292 # path first. bootpath will later be modified in mpxio-upgrade 395*5a4c37c9Sqh201292 # to the vhci-based path if mpxio is enabled on root. 396*5a4c37c9Sqh201292 get_newbootpath_for_stmsdev 397*5a4c37c9Sqh201292 if [ $? -ne 0 ]; then 398*5a4c37c9Sqh201292 gettext "failed to update bootpath.\n" 1>&2 399*5a4c37c9Sqh201292 return 1 400*5a4c37c9Sqh201292 fi 401*5a4c37c9Sqh201292 fi 4027c478bd9Sstevel@tonic-gate update_sysfiles 4037c478bd9Sstevel@tonic-gateelif [ "x$cmd" = xlist ]; then 4047c478bd9Sstevel@tonic-gate $STMSBOOTUTIL -l $controller 4057c478bd9Sstevel@tonic-gateelse 4067c478bd9Sstevel@tonic-gate $STMSBOOTUTIL -L 4077c478bd9Sstevel@tonic-gatefi 4087c478bd9Sstevel@tonic-gate 4097c478bd9Sstevel@tonic-gateexit $? 410