stmsboot.sh revision 60fffc19b6d98cdde54f6ad4c249f6cd4560d04b
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "%Z%%M% %I% %E% SMI"
GUID=
SUPPORTED_DRIVERS="fp|mpt"
export TEXTDOMAIN
CLIENT_TYPE_VHCI="/scsi_vhci.*/ssd@|/scsi_vhci.*/disk@"
# The phci client type egrep string will change based on the
# drivers which we are operating on, and the cpu architecture
# and we call stmsboot_util -n -D $drv to get that string
#
# Copy all entries (including comments) from source driver.conf
# to destination driver.conf except those entries which contain
# the mpxio-disable property.
# Take into consideration entries that spawn more than one line.
#
# $1 source driver.conf file
# $2 destination driver.conf file
#
# Returns 0 on success, non zero on failure.
#
{
sed '
/^[ ]*#/{ p
d
}
s/[ ]*$//
/^$/{ p
d
}
/mpxio-disable[ ]*=.*;$/{ w '$3'
d
}
/;$/{ p
d
}
:rdnext
N
s/[ ]*$//
/[^;]$/b rdnext
/mpxio-disable[ ]*=/{ s/\n/ /g
w '$3'
d
}
' $1 > $2
return $?
}
#
# backup the last saved copy of the specified files.
# $* files to backup
#
{
do
fi
done
}
#
# build recover instructions
#
# $1 1 to include boot script in the instructions
# 0 otherwise
#
{
gettext "Instructions to recover your previous STMS configuration (if in case the system does not boot):\n\n" > $RECOVERFILE
gettext "\tUndo the modifications you made to STMS configuration.\n\tFor example undo any changes you made to " >> $RECOVERFILE
else
fi
if [ $1 -ne 0 ]; then
fi
fi
gettext "was your root device,\nbut it could be named differently after you boot net.\n" >> $RECOVERFILE
}
#
# during the next reboot. If the cmd is "enable" or "disable", copy
# $TMPDRVCONF to $KDRVCONF.
#
# Returns 0 on success, 1 on failure.
#
{
gettext "WARNING: This operation will require a reboot.\nDo you want to continue ? [y/n] (default: y) "
read response
TMPDRVCONF=/var/run/tmp.$d.conf.$$
rm -f $TMPDRVCONF > /dev/null 2>&1
done;
return 0;
fi
TMPDRVCONF=/var/run/tmp.$d.conf.$$
rm -f $TMPDRVCONF > /dev/null 2>&1
#
# there is no need to update the system files in the following
# cases:
# - we are enabling mpxio and the system has no configured
# disks accessible by phci paths.
# - we are disabling mpxio and the system has no configured
# disks accessible by vhci paths.
#
continue;
fi
$EGREP -s "$CLIENT_TYPE_PHCI"
else
$EGREP -s "$CLIENT_TYPE_VHCI"
fi
if [ $? -ne 0 ]; then
fi
done
fi
# then we cannot disable mpxio for that controller. Yet.....
# This code block is an ugly hack and when we either get full-time
# mpxio for all devices, or devfsadm gets re-written then we can
# remove it. For now, though, we have to see the beauty in ugly.
# check that we haven't already got this entry
# if [ -z "$EXISTP" ]; then
if [ $? != 0 ]; then
# This entry must be the last one in the fp.conf file
# to ensure that the boot path mpxio setting is not
# accidentally overridden
name="fp" parent="$NNEWP" port=0 mpxio-disable="no";
EOF
fi
fi
fi
#only update bootpath for x86.
fi
#
# Enable the mpxio-upgrade service, but don't run it now.
# The service will run during the next reboot and will do
# the actual job of modifying the system files.
#
svccfg -f - << EOF
select $STMSINSTANCE
setprop general/enabled = true
EOF
fi
fi
gettext "The changes will come into effect after rebooting the system.\nReboot the system now ? [y/n] (default: y) "
read response
fi
return 0
}
#
# Enable or disable mpxio as specified by the cmd.
# Returns 0 on success, 1 on failure.
#
# Args: $cmd = {enable | disable}
# $d = {fp | mpt}
#
# the global variable $DRVLIST is used
#
{
mpxiodisableno='mpxio-disable[ ]*=[ ]*"no"[ ]*;'
mpxiodisableyes='mpxio-disable[ ]*=[ ]*"yes"[ ]*;'
else
fi
TMPDRVCONF=/var/run/tmp.$d.conf.$$
echo "Checking mpxio status for driver $d"
if [ -s $TMPDRVCONF_MPXIO_ENTRY ]; then
# $DRVCONF does have mpxiodisable entries
if [ $? -ne 0 ]; then
rm -f $TMPDRVCONF $TMPDRVCONF_MPXIO_ENTRY > /dev/null 2>&1
continue;
else
reboot_needed=`$EXPR $reboot_needed + 1`
fi
# If mpxiodisable entries do not exist, always continue update
fi
else
rm -f $TMPDRVCONF $TMPDRVCONF_MPXIO_ENTRY > /dev/null 2>&1
return 1
fi
rm $TMPDRVCONF_MPXIO_ENTRY > /dev/null 2>&1
}
setcmd()
{
cmd=$1
else
exit 2
fi
}
#
#Need to update bootpath on x86 if boot system from FC disk
#Only update bootpath here when mpxio is enabled
#If mpxio is disabled currently, will update bootpath in mpxio-upgrade
#
return 0
fi
cur_bootpath=`eeprom bootpath | \
return 1
fi
#only update bootpath for STMS path
echo $cur_bootpath|$EGREP $CLIENT_TYPE_VHCI > /dev/null 2>&1
if [ $? -eq 1 ]; then
return 0
fi
if [ $? -ne 0 ]; then
new_bootpath=""
return 1
fi
# we replace "sd" with "disk" if we need to work on the eeprom
# bootpath setting, since fibre-channel devices will report as
# being attached via "disk" and not "sd". One day we'll have a
# truly unified and architecture-independent view of the device
# tree, and this block will be redundant
fp_bootpath=`echo $new_bootpath|grep fp.*sd`
fi
}
#
# Emit a warning message to the user that by default we
# operate on all multipath-capable controllers that are
# attached to the system, and that if they want to operate
# on only a specific controller type (fp|mpt|....) then
# they need to re-invoke stmsboot with "-D $driver" in
# their argument list
#
# for each driver that we support, grab the list
# of controllers attached to the system.
echo "WARNING: stmsboot operates on each supported multipath-capable controller"
echo " detected in a host. In your system, these controllers are"
done;
echo ""
echo "If you do NOT wish to operate on these controllers, please quit stmsboot"
echo "and re-invoke with -D { fp | mpt } to specify which controllers you wish"
echo "to modify your multipathing configuration for."
echo
read response
exit
fi
}
# Function to setup the CLIENT_TYPE_PHCI string based on
# the list of drivers that we're operating on. The variable
# depends upon the pathname of the parent node in the
# stmsboot_util -n provides us with the name of the
# node containing "fp" or "sas-$d", and helpfully
# appends "/[ssd|sd]@" as appropriate
d=$1;
TLIST=`$STMSBOOTUTIL -D $d -n`
else
fi
}
# process options
while getopts D:geduLl: c
do
case $c in
g) GUID="-g";;
exit 2;;
esac
done
exit 2
fi
if [ "x$DRV" = "x" ]; then
DRVLIST="fp mpt"
else
fi
exit 1
fi
# just a sanity check
if [ ! -f $STMSBOOTUTIL -o ! -f $STMSMETHODSCRIPT ]; then
exit 1
fi
# If the old sun4u-specific SMF method is found, remove it
if [ $? -ne 0 ]; then
fi
# now import the new service, if necessary
if [ $? -ne 0 ]; then
if [ $? -ne 0 ]; then
exit 1
else
fi
else
exit 1
fi
fi
#
# The bootup script doesn't work on cache-only-clients as the script
# is executed before the plumbing for cachefs mounting of root is done.
#
gettext "This command option is not supported on systems with nfs or cachefs mounted root filesystem.\n" 1>&2
exit 1
fi
if [ -d $SAVEDIR ]; then
#
# keep a copy of the last saved files, useful for manual
# recovery in case of a problem.
#
if [ "x$MACH" = "xsparc" ]; then
else
fi
done
else
fi
fi
if [ -n "$msgneeded" ]; then
fi
done
# Need to update bootpath on x86 if our boot device is
# now accessed through mpxio.
# Only update bootpath before reboot when mpxio is enabled
# If mpxio is currently disabled, we will update bootpath
# on reboot in the mpxio-upgrade service
if [ $? -ne 0 ]; then
return 1
fi
fi
else
echo "STMS is already ${cmd}d. No changes or reboots needed"
fi
if [ "x$MACH" = "xi386" ]; then
# In this case we always change the bootpath to phci-based
# path first. bootpath will later be modified in mpxio-upgrade
# to the vhci-based path if mpxio is enabled on root.
if [ $? -ne 0 ]; then
return 1
fi
fi
else
fi
exit $?