#
# 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 2015 Nexenta Systems, Inc. All rights reserved.
#
#
GUID=
SUPPORTED_DRIVERS="fp|mpt|mpt_sas|pmcs"
export TEXTDOMAIN
new_bootpath=""
CLIENT_TYPE_VHCI="/scsi_vhci"
#
# 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.
#
{
# be careful here, we've got embedded \t characters
# in sed's pattern space.
$SED '
/^[ ]*#/{ p
d
}
s/[ ]*$//
/^$/{ p
d
}
/mpxio-disable[ ]*=.*;$/{ w '$3'
d
}
/disable-sata-mpxio[ ]*=.*;$/{ w '$4'
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
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 -eq 1 ]; 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.\n"
gettext "Do 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
# set need_bootscript to the number of drivers that
# we support.
TMPDRVCONF=/var/run/tmp.$d.conf.$$
if [ -f $TMPDRVCONF ]; then
$RM -f $TMPDRVCONF
else
# if $TMPDRVCONF doesn't exist, then we
# haven't made any changes to it
continue;
fi
#
# 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.
#
# 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
continue;
fi
$EGREP -s "$CLIENT_TYPE_PHCI"
else
$EGREP -s "$CLIENT_TYPE_VHCI"
fi
if [ $? -ne 0 ]; then
fi
done
fi
if [ $need_bootscript -gt 0 ]; then
#only update bootpath for x86.
fi
# Disable Fast Reboot temporarily for the next reboot only.
HASZFSROOT=`$DF -g / |$GREP zfs`
$SVCCFG -s $FASTBOOTINSTANCE addpg config_ovr application P > /dev/null 2>&1
$SVCCFG -s $FASTBOOTINSTANCE \
setprop config_ovr/fastreboot_default=boolean:\"false\"
$SVCCFG -s $FASTBOOTINSTANCE \
setprop config_ovr/fastreboot_onpanic=boolean:\"false\"
fi
fi
# Enable the mpxio-upgrade service for the reboot
$SVCCFG -s $STMSINSTANCE "setprop general/enabled=true"
else
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 | mpt_sas | pmcs}
#
# the global variable $DRVLIST is used
#
{
# be careful here, we've got embedded \t characters
# in sed's pattern space.
mpxiodisableno='mpxio-disable[ ]*=[ ]*"no"[ ]*;'
mpxiodisableyes='mpxio-disable[ ]*=[ ]*"yes"[ ]*;'
satadisableno='disable-sata-mpxio[ ]*=[ ]*"no"[ ]*;'
satadisableyes='disable-sata-mpxio[ ]*=[ ]*"yes"[ ]*;'
else
fi
TMPDRVCONF=/var/run/tmp.$d.conf.$$
if delete_mpxio_disable_entries $KDRVCONF $TMPDRVCONF $TMPDRVCONF_MPXIO_ENTRY $TMPDRVCONF_SATA_ENTRY; then
if [ -s $TMPDRVCONF_MPXIO_ENTRY ]; then
# $DRVCONF does have mpxiodisable entries
if [ $? -eq 0 ]; then
reboot_needed=`$EXPR $reboot_needed + 1`
else
reboot_needed=`$EXPR $reboot_needed + 1`
else
return 0;
fi
fi
# If mpxiodisable entries do not exist, always continue update
fi
else
return 1
fi
if [ "$d" = "mpt" ]; then
fi
}
{
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 currently disabled, then we'll update bootpath in the
# mpxio-upgrade service method on reboot.
#
return 0
fi
if [ $? != 0 ]; then
return 1
fi
# Since on x64 platforms the eeprom command doesn't update the
# kernel, the file /boot/solaris/bootenv.rc and the kernel's
# bootpath variable have a good chance of differing. We do some
# extra handwaving to get the correct bootpath variable setting.
fi
NEWBOOTPATH=""
for path in $cur_bootpath; do
mapped=`$STMSBOOTUTIL -p $path`
else
fi
fi
done
# now strip off leading and trailing space chars
new_bootpath=`echo $NEWBOOTPATH`
return 0
}
#
# 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|mpt_sas|pmcs|....) 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 ""
gettext "WARNING: stmsboot operates on each supported multipath-capable controller\n"
gettext " detected in a host. In your system, these controllers are\n\n"
$STMSBOOTUTIL -D $WARNDRV -n
done;
echo ""
gettext "If you do NOT wish to operate on these controllers, please quit stmsboot\n"
gettext "and re-invoke with -D { fp | mpt | mpt_sas | pmcs} to specify which controllers you wish\n"
gettext "to modify your multipathing configuration for.\n"
echo ""
read response
exit
fi
}
#
#
# main starts here
#
# process options
while getopts D:geduLl: c
do
case $c in
g) GUID="-g";;
exit 2;;
esac
done
if [ "$cmd" = "none" ]; then
exit 2
fi
if [ -z "$DRV" ]; then
DRVLIST="fp mpt mpt_sas pmcs"
else
fi
if [ -z "$USERID" ]; then
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 [ $? -eq 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
# make sure we can stash our data somewhere private
if [ ! -d $SAVEDIR ]; then
fi
# prime the cache
gettext "This command option is not supported on systems with an nfs mounted root filesystem.\n" 1>&2
exit 1
fi
# if the user has left the system with the mpxio-upgrade service
# in a temporarily disabled state (ie, service is armed for the next
# reboot), then let them know. We need to ensure that the system is
# is in a sane state before allowing any further invocations, so
# try to get the system admin to do so
if [ ! $? ]; then
echo ""
gettext "You need to reboot the system in order to complete\n"
gettext "the previous invocation of stmsboot.\n"
echo ""
gettext "Do you wish to reboot the system now? (y/n, default y) "
read response
"$response" = "y" ]; then
else
echo ""
gettext "Please reboot this system before continuing\n"
echo ""
exit 1
fi
fi
#
# keep a copy of the last saved files, useful for manual
# recovery in case of a problem.
#
if [ "$MACH" = "sparc" ]; then
else
fi
done
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 [ "$cmd" = "disable" ]; then
if [ "$MACH" = "i386" ]; then
if [ $? -ne 0 ]; then
return 1
fi
fi
# If we're not using ZFS root then we need
# to keep track of what / maps to in case
# it's an active-active device and we boot from
# the other path
HASZFSROOT=`$DF -g / |$GREP zfs`
if [ -z "$HASZFSROOT" ]; then
fi
fi
else
echo "STMS is already ${cmd}d. No changes or reboots needed"
fi
elif [ "$cmd" = "update" ]; then
if [ "$MACH" = "i386" ]; 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
elif [ "$cmd" = "list" ]; then
else
fi
exit $?