postinstall revision fcf3ce441efd61da9bb2884968af01cb7c1452cc
#!/bin/sh
# 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
# or http://www.opensolaris.org/os/licensing.
# 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 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Set path
#
PATH="/usr/bin:/usr/sbin:${PATH}"
export PATH
#
# Set variables
#
DRVDIR64=${BASEDIR}/usr/kernel/drv/sparcv9
DRVDIR=${BASEDIR}/usr/kernel/drv
TMP=/tmp/${PKGINST}.$$
ERROR_LOG=${TMP}.errorlog
EXIT=0
FAILURE=1
FS_LOCAL_SVC="svc:/system/filesystem/local"
MODBUSYMSG="
#### NOTICE #####\n
The previous version of this software cannot be unloaded (busy).\n
To load the new modules you must reboot the system."
MODBUSY=0
MODULE="sv"
OS_VER=`eval uname -r`
PKG_INSTALL_ROOT=${PKG_INSTALL_ROOT:=/}
DEVLINKTB="${PKG_INSTALL_ROOT}/etc/devlink.tab"
DSCFG_UPGRADE="${PKG_INSTALL_ROOT}/etc/opt/SUNWesm/dscfg.cf.upgrade"
if [ "$BASEDIR" = "/" ]
then
unset BASEDIR
fi
#
# Set alternate command syntax (if needed)
#
# For least privileges add option -P sys_devices,sys_config
if [ "${PKG_INSTALL_ROOT}" = "/" ]
then
ADD_DRV="add_drv -P sys_devices,sys_config"
REM_DRV="rem_drv"
else
ADD_DRV="add_drv -P sys_devices,sys_config -b ${PKG_INSTALL_ROOT}"
REM_DRV="rem_drv -b ${PKG_INSTALL_ROOT}"
fi
#
# Functions
#
message()
{
echo ""
echo "$@"
echo ""
}
add_devlink()
{
PATTERN="$1"
LINK="$2"
echo "$PATTERN\t$LINK" >>${DEVLINKTB}
}
#
# Setup the service to enable. This is necessary to deal
# with upgrade situations. It also sets the proper dependency type for the
# local filesystems service
# $1: name of service to enable
#
enable_service_on_reboot()
{
# enable the service
svcadm enable -s svc:/system/$1
if [ $? -ne 0 ]
then
message "Warning: Unable to enable $1 service"
fi
# workaround for 6221374--let local-fs know that it depends on us
svcadm refresh ${FS_LOCAL_SVC}:default
if [ $? -ne 0 ]
then
message "Warning: Unable to refresh $1 service"
fi
# make sure the local filesystems service waits for us
svccfg -s $FS_LOCAL_SVC setprop ${1}-local-fs/grouping=require_all
if [ $? -ne 0 ]
then
message "Warning: Unable to set dependency for $1 service"
fi
svcadm refresh ${FS_LOCAL_SVC}:default
if [ $? -ne 0 ]
then
message "Warning: Unable to refresh $1 service"
fi
}
#
# Error messages
#
REMERR="
ERROR: The installation cannot be completed due to an error removing the
${MODULE} loadable module. The file ${ERROR_LOG} contains the errors.
Exiting...Please fix problem and re-run pkgadd."
ADDERR="
ERROR: The installation cannot be completed due to an error adding the
${MODULE} loadable module. The file ${ERROR_LOG} contains the errors.
Exiting...Please fix problem and re-run pkgadd."
DEVLINKERR="
ERROR: The installation cannot be completed due to an error configuring the
${MODULE} loadable module. The file ${ERROR_LOG} contains the errors.
Exiting...Please fix problem and re-run pkgadd."
#
# Finalize changes to the pkg database
#
installf -R ${PKG_INSTALL_ROOT} -f ${PKGINST}
removef -R ${PKG_INSTALL_ROOT} -f ${PKGINST} >/dev/null 2>&1
# if the sv module is still loaded then it has refused to unload
# and we have to force a reboot.
#
if [ "${PKG_INSTALL_ROOT:-/}" = "/" ]; then
modinfo | grep -w sv > /dev/null 2>&1
if [ $? -eq 0 ] ; then
# still loaded
MODBUSY=1
NOPT="-b /"
EXIT=10
fi
fi
#
# if module has been previously installed, unload and remove it...
#
grep -w ${MODULE} ${PKG_INSTALL_ROOT}/etc/name_to_major > /dev/null
if [ $? -eq 0 ]
then
${REM_DRV} ${MODULE} > ${ERROR_LOG} 2>&1
[ $? -ne 0 ] && {
message ${REMERR}
exit ${FAILURE}
}
fi
#
# install module
#
add_devlink "type=ddi_pseudo;name=${MODULE}" '\D'
${ADD_DRV} $NOPT -m '* 0666 root sys' ${MODULE} > ${ERROR_LOG} 2>&1
[ $? -ne 0 ] && {
message ${ADDERR}
exit ${FAILURE}
}
# deal with upgrades from AVS3.2
if [ -f $DSCFG_UPGRADE ]
then
grep $PKGINST $DSCFG_UPGRADE > /dev/null
if [ $? = 1 ]
then
enable_service_on_reboot nws_sv
echo "$PKGINST" >> $DSCFG_UPGRADE
fi
fi
if [ $MODBUSY = 1 ]
then
message $MODBUSYMSG
fi
exit $EXIT