postremove revision 7c478bd95313f5f23a4c958a745db2134aa03244
342N/A#! /bin/sh
1472N/A#
342N/A# CDDL HEADER START
342N/A#
342N/A# The contents of this file are subject to the terms of the
342N/A# Common Development and Distribution License, Version 1.0 only
342N/A# (the "License"). You may not use this file except in compliance
342N/A# with the License.
342N/A#
342N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
342N/A# or http://www.opensolaris.org/os/licensing.
342N/A# See the License for the specific language governing permissions
342N/A# and limitations under the License.
342N/A#
342N/A# When distributing Covered Code, include this CDDL HEADER in each
342N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
342N/A# If applicable, add the following below this CDDL HEADER, with the
342N/A# fields enclosed by brackets "[]" replaced with your own identifying
1472N/A# information: Portions Copyright [yyyy] [name of copyright owner]
1472N/A#
1472N/A# CDDL HEADER END
342N/A#
342N/A
342N/A# ident "%Z%%M% %I% %E% SMI"
342N/A# SUNWpd postremove script
342N/A# Copyright (c) 1995,1999-2000 by Sun Microsystems, Inc.
342N/A# All rights reserved.
942N/A
942N/Akillproc() { # kill the named process(es)
342N/A pid=`/usr/bin/ps -e |
342N/A /usr/bin/grep $1 |
342N/A /usr/bin/sed -e 's/^ *//' -e 's/ .*//'`
1394N/A [ "$pid" != "" ] && kill $pid
342N/A}
342N/A
342N/A
342N/APATH="/usr/bin:/usr/sbin:${PATH}"
342N/Aexport PATH
342N/Astatus=0
342N/A
342N/ANAMEMAJOR="${BASEDIR}/etc/name_to_major"
342N/AMINORPERM="${BASEDIR}/etc/minor_perm"
342N/ADEVLINKTB="$BASEDIR/etc/devlink.tab"
342N/ADRIVERALS="$BASEDIR/etc/driver_aliases"
342N/A
342N/Arm -f /dev/pmc
342N/A
342N/Aif test ! -f ${NAMEMAJOR} -o ! -w ${NAMEMAJOR}
342N/Athen
342N/A echo "rem_major: data file \'${NAMEMAJOR}\' is missing/inaccessible." >&2
342N/A exit 1
342N/Afi
342N/A
342N/Aif test ! -f ${MINORPERM} -o ! -w ${MINORPERM}
342N/Athen
342N/A echo "rem_minor: data file \'${MINORPERM}\' is missing/inaccessible." >&2 exit 1
342N/Afi
342N/A
342N/Aif test ! -f ${DEVLINKTB} -o ! -w ${DEVLINKTB}; then
342N/A echo "rem_devlink: data file ${DEVLINKTB} is missing/inaccessible." >&2
342N/A exit 1
342N/Afi
342N/A
342N/Aif test ! -f ${DRIVERALS} -o ! -w ${DRIVERALS}; then
342N/A echo "rem_drv_alias: data file ${DRIVERALS} is missing/inaccessible." >&2
342N/A exit 1
342N/Afi
342N/A
342N/Atrap "rm -f /tmp/$$.*;exit 1" 1 2 3 13 15
342N/ATMP=/tmp/$$
342N/A
342N/A# removes major numbers from system for device drivers
342N/A# Usage:
342N/A# rem_major name1 name2 name3 name4 ....
342N/A
342N/Arem_major()
342N/A{
342N/Asort +1 -2n ${NAMEMAJOR} | nawk '#
342N/ANR == 1 {n=split(namelist,x)
342N/A if (n < 1)
342N/A exit(1)
342N/A for (i=1; i<=n; i++)
342N/A chklist[x[i]]++
342N/A }
342N/A {if ($1 in chklist)
342N/A print
342N/A }
342N/A' namelist="$*" - > $TMP.del
342N/Aif [ -s $TMP.del ]
342N/Athen
342N/A fgrep -v -x -f $TMP.del ${NAMEMAJOR} | sort +1 -2n -o ${NAMEMAJOR}
342N/Afi
342N/A}
342N/A
342N/A
342N/A# removes minor permissions from system for device drivers
342N/A# Usage:
342N/A# rem_minor name1 name2 name3 name4 ....
342N/A# i.e.
342N/A# rem_minor 'sd:*' 'sd:a'
342N/A
342N/Arem_minor()
342N/A{
342N/Afor p in "$@"
342N/Ado echo "$p"
342N/Adone | nawk '#
342N/AFILENAME != "-" {permtab[$1] = $0;next}
342N/AFILENAME == "-" {
342N/A if ($1 !~ /:/) {
342N/A printf("Bad name:minor pair: %s, skipping.\n", $1)
342N/A next
342N/A }
342N/A if ($1 in permtab)
342N/A print permtab[$1] >> permdel
342N/A next
342N/A }
342N/A' permdel=$TMP.perm ${MINORPERM} - >&2
342N/A
342N/Aif [ -s $TMP.perm ]
342N/Athen
342N/A fgrep -v -x -f $TMP.perm ${MINORPERM} | sort +0 -1 -o ${MINORPERM}
342N/Afi
342N/A}
342N/A
342N/A
616N/A# removes entries from devlink.tab file
616N/A# Usage:
616N/A# rem_devlink spec1 spec2 spec3 spec4 ...
616N/A#
616N/A# where each <spec> is:
616N/A# <devfs-spec> <dev-name> <dev-link>
616N/A#
616N/A#
342N/A
342N/Arem_devlink()
1394N/A{
342N/Awhile test $# -ge 2
545N/Ado
342N/Aecho "$1 $2"
342N/Ashift 2
342N/Adone | nawk '-F ' '#
342N/AFILENAME != "-" {devlinktab[$1] = $0;next}
342N/AFILENAME == "-" {if ($1 in devlinktab)
342N/A print devlinktab[$1] >> devlinktmp
342N/A }
342N/A' devlinktmp=$TMP.devlink ${DEVLINKTB} - >&2
342N/A
342N/Aif [ -s $TMP.devlink ]
342N/Athen
342N/A fgrep -v -x -f $TMP.devlink ${DEVLINKTB} > $TMP.devlinknew && \
342N/A cp $TMP.devlinknew ${DEVLINKTB}
342N/Afi
342N/A}
342N/A
342N/A
545N/A# removes entries to driver_aliases file
342N/A# Usage:
342N/A# rem_drv_alias spec1 spec2 spec3
342N/A#
342N/A# where spec is:
545N/A# <driver> <alias>
342N/A#
342N/A
342N/Arem_drv_alias()
342N/A{
342N/Awhile test $# -ge 2
342N/Ado
342N/A echo "$1 $2"
342N/A shift 2
342N/Adone | nawk '#
342N/AFILENAME != "-" {drvalias[$1] = $0;next}
342N/AFILENAME == "-" {if ($1 in drvalias)
342N/A print drvalias[$1] >> drvaliastmp
342N/A }
342N/A' drvaliastmp=$TMP.drvalias ${DRIVERALS} - >&2
342N/A
342N/Aif [ -s $TMP.drvalias ]
342N/Athen
342N/A# echo Removing
342N/A# cat $TMP.drvalias
342N/A
342N/A fgrep -v -x -f $TMP.drvalias ${DRIVERALS} > $TMP.drvaliasnew && \
342N/A cp $TMP.drvaliasnew ${DRIVERALS}
342N/Afi
342N/A}
342N/A
545N/A# Remove drivers if installed
342N/Amodnum=`grep -c ecpp ${NAMEMAJOR}`
342N/Aif [ "$modnum" = "1" ]; then
342N/A /usr/sbin/rem_drv -b ${BASEDIR} ecpp || status=1
342N/Afi
342N/A
342N/Arm -f /tmp/$$.*
342N/A
342N/Aexit $status
342N/A