preremove revision fcf3ce441efd61da9bb2884968af01cb7c1452cc
1N/A#!/bin/sh
1N/A# CDDL HEADER START
1N/A#
1N/A# The contents of this file are subject to the terms of the
1N/A# Common Development and Distribution License (the "License").
1N/A# You may not use this file except in compliance with the License.
1N/A#
1N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1N/A# or http://www.opensolaris.org/os/licensing.
1N/A# See the License for the specific language governing permissions
1N/A# and limitations under the License.
1N/A#
1N/A# When distributing Covered Code, include this CDDL HEADER in each
1N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1N/A# If applicable, add the following below this CDDL HEADER, with the
1N/A# fields enclosed by brackets "[]" replaced with your own identifying
1N/A# information: Portions Copyright [yyyy] [name of copyright owner]
1N/A#
1N/A# CDDL HEADER END
1N/A#
1N/A#
1N/A# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
1N/A# Use is subject to license terms.
1N/A#
1N/A
1N/A#
1N/A# Set path
1N/A#
1N/APATH="/usr/bin:/usr/sbin:${PATH}"
1N/Aexport PATH
1N/A
1N/A#
1N/A# Set variables
1N/A#
1N/ADEVLINKTB="${PKG_INSTALL_ROOT}/etc/devlink.tab"
1N/AFAILURE=1
1N/ANAMEMAJOR="${PKG_INSTALL_ROOT}/etc/name_to_major"
1N/APKG_INSTALL_ROOT=${PKG_INSTALL_ROOT:=/}
1N/A# reconfig order
1N/ACFGMODULES="nskern ncall nsctl sdbc"
1N/A# reverse dependency order
1N/ARMODULES="sdbc nsctl ncall nskern"
1N/ATMP=/tmp/${PKGINST}.$$
1N/ATMPFILE="/tmp/file.$$"
1N/ADSCFG_UPGRADE="${PKG_INSTALL_ROOT}/var/svc/profile/dscfg_upgrade"
1N/ASVC=nws_scm
1N/AFS_LOCAL_SVC="svc:/system/filesystem/local"
1N/A
1N/A#
1N/A# Set alternate command syntax (if needed)
1N/A#
1N/A
1N/Aif [ "${PKG_INSTALL_ROOT}" = "/" ]; then
1N/A REM_DRV="rem_drv"
1N/Aelse
1N/A REM_DRV="rem_drv -b ${PKG_INSTALL_ROOT}"
1N/Afi
1N/A
1N/A#
1N/A# Functions
1N/A#
1N/A
1N/A# rem_devlink - remove entry from ${DEVLINKTB}
1N/Arem_devlink()
1N/A{
1N/A PATTERN="$1"
1N/A grep -vw $PATTERN ${DEVLINKTB} > ${TMP}.devlink
1N/A if [ $? -eq 0 ]; then
1N/A mv ${TMP}.devlink ${DEVLINKTB}
1N/A else
1N/A rm ${TMP}.devlink
1N/A fi
1N/A}
1N/A
1N/A# reconfig modules, to prevent error caused from manual unload
1N/A# This is workaround for 6255461
1N/A
1N/Aif [ "$WORKAROUND_6255461" = "1" ]; then
1N/A for MDL in ${CFGMODULES}
1N/A do
1N/A devfsadm -i ${MDL}
1N/A done
1N/Afi
1N/A
1N/A#
1N/A# Disable the service, if it is imported
1N/A#
1N/Asvcprop -q -p general/entity_stability svc:/system/${SVC}
1N/A# are we imported?
1N/Aif [ $? = 0 ]
1N/Athen
1N/A svcadm disable -s svc:/system/${SVC}
1N/A svccfg -s $FS_LOCAL_SVC setprop ${SVC}-local-fs/grouping=optional_all
1N/Afi
1N/A
1N/A
1N/A#
1N/A# Remove modules.
1N/A#
1N/A
1N/Afor MODULE in ${RMODULES}
1N/Ado
1N/A ERRLOG=/tmp/${MODULE}.prermlog
1N/A REMOVERR="ERROR: The removal cannot be completed due to an error \
1N/A removing the ${MODULE} loadable module. The file ${ERRLOG} \
1N/A contains the errors. Exiting..."
1N/A
1N/A if grep -w ${MODULE} ${NAMEMAJOR} >/dev/null; then
1N/A ${REM_DRV} ${MODULE} > ${ERRLOG} 2>&1
1N/A [ $? -ne 0 ] && {
1N/A message ${REMOVERR}
1N/A exit ${FAILURE}
1N/A }
1N/A fi
1N/A
1N/A /usr/bin/rm -f ${PKG_INSTALL_ROOT}/dev/${MODULE}
1N/A /usr/bin/rm -f $DSCFG_UPGRADE
1N/A rem_devlink ${MODULE}
1N/A /usr/bin/rm -f ${ERRLOG}
1N/A
1N/A MODID=`modinfo | grep -w $MODULE | awk '{print $1}'`
1N/A if [ -n "$MODID" ]
1N/A then
1N/A modunload -i ${MODID}
1N/A if [ $? != 0 ]
1N/A then
1N/A echo "Error: Failed to unload $MODULE module."
1N/A exit 1
1N/A fi
1N/A fi
1N/A
1N/Adone
1N/A
1N/A# Since spuni is not configured via add_drv, we cannot rely on rem_drv to
1N/A# unload it. If it's still loaded, try to unload it.
1N/AMODID=`modinfo | grep -w spuni | awk '{print $1}'`
1N/Aif [ -n "$MODID" ]
1N/Athen
1N/A modunload -i ${MODID}
1N/A if [ $? != 0 ]
1N/A then
1N/A echo "Warning: Failed to unload spuni module."
1N/A exit 1
1N/A fi
1N/Afi
1N/A
1N/A# ignore any failures to modunload spuni
1N/Aexit 0
1N/A