postinstall revision 7a1306a70fee0e017a445bde1dcfd1997f691cf4
4133N/A#! /usr/bin/sh
4133N/A#
4133N/A# CDDL HEADER START
4133N/A#
4133N/A# The contents of this file are subject to the terms of the
4133N/A# Common Development and Distribution License, Version 1.0 only
4133N/A# (the "License"). You may not use this file except in compliance
4133N/A# with the License.
4133N/A#
4133N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
4133N/A# or http://www.opensolaris.org/os/licensing.
4133N/A# See the License for the specific language governing permissions
4133N/A# and limitations under the License.
4133N/A#
4133N/A# When distributing Covered Code, include this CDDL HEADER in each
4133N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
4133N/A# If applicable, add the following below this CDDL HEADER, with the
4133N/A# fields enclosed by brackets "[]" replaced with your own identifying
4133N/A# information: Portions Copyright [yyyy] [name of copyright owner]
4133N/A#
5680N/A# CDDL HEADER END
4133N/A#
5680N/A#
5680N/A# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
5680N/A# Use is subject to license terms.
4724N/A#
4133N/A# ident "%Z%%M% %I% %E% SMI"
4133N/A#
4133N/A
5835N/A# Driver info
5835N/ADRV=ath
5835N/ADRVALIAS='"pci168c,13" "pci168c,1014"'
4133N/A
5835N/ABASEDIR=${BASEDIR:-/}
4723N/A
4133N/A# Function: check_add_drv()
4133N/A#
4133N/A# This function will check if add_drv has been executed.
6007N/A# If not simply calls add_drv. Otherwise adds entries to
6007N/A# driver_aliases, driver_classes and minor_perm if necessary.
6007N/A# The syntax of this function is the same as add_drv.
6007N/A
6007N/Acheck_add_drv()
6007N/A{
6007N/A CMD=$*
6007N/A shift
5835N/A
5835N/A ALIAS=""
5835N/A CLASS=""
5835N/A MPERM=""
5835N/A ALIASDIR=${BASEDIR}/etc/driver_aliases
5680N/A CLASSDIR=${BASEDIR}/etc/driver_classes
5680N/A MPERMDIR=${BASEDIR}/etc/minor_perm
5835N/A while getopts i:c:m opt 2>/dev/null; do
5680N/A case "$opt" in
4133N/A i) ALIAS=`echo ${OPTARG} | /usr/bin/sed -e "s/'//g"`
5835N/A ;;
5835N/A c) CLASS=${OPTARG}
5835N/A ;;
4723N/A m) MPERM=${OPTARG}
4723N/A ;;
4723N/A esac
4133N/A done
4133N/A shift `/usr/bin/expr ${OPTIND} - 1`
5680N/A DRIVER=$1
5680N/A
5680N/A # Make sure add_drv has not been previously executed
5680N/A # before attempting to add the driver
4133N/A /usr/bin/egrep -s "^${DRIVER}[ ]" $BASEDIR/etc/name_to_major
4133N/A
4133N/A if [ $? -ne 0 ]; then
4133N/A eval ${CMD}
4133N/A if [ $? -ne 0 ]; then
4133N/A echo "Failed add_drv ${DRIVER}!\n" >&2
4133N/A exit 1
5835N/A fi
5835N/A else
5835N/A # Add driver entry if necessary
5835N/A if [ -n "${ALIAS}" ]; then
4133N/A for i in ${ALIAS}; do
4133N/A /usr/bin/egrep -s "^${DRIVER}[ ]+$i" ${ALIASDIR}
4133N/A if [ $? -ne 0 ]; then
4133N/A echo "${DRIVER} $i" >> ${ALIASDIR}
4133N/A fi
4133N/A done
4133N/A fi
4133N/A
4133N/A if [ -n "${CLASS}" ]; then
4133N/A /usr/bin/egrep -s "^${DRIVER}[ ]+${CLASS}" ${CLASSDIR}
4133N/A if [ $? -ne 0 ]; then
4133N/A echo "${DRIVER}\t${CLASS}" >> ${CLASSDIR}
4133N/A fi
4133N/A fi
4133N/A
4133N/A if [ -n "${MPERM}" ]; then
4133N/A /usr/bin/egrep -s "^${DRIVER}:" ${MPERMDIR}
4133N/A if [ $? -ne 0 ]; then
4133N/A echo "${DRIVER}:${PERM}" >> ${MPERMDIR}
4133N/A fi
4133N/A fi
4133N/A fi
4133N/A}
4133N/A
5835N/A# Is the hardware there?
4723N/Ahw_exists=0
4723N/ACLEANALIAS=`echo ${DRVALIAS} | /usr/bin/sed -e 's/\"//g'`
4133N/Afor i in ${CLEANALIAS}
4133N/Ado
5835N/A prtconf -v | /usr/bin/egrep -s $i
4133N/A if [ $? -eq 0 ]
4133N/A then
4133N/A hw_exists=1
4133N/A fi
4133N/Adone
4133N/A
5795N/A# Only attempt to attach the driver on a running
5795N/A# system with the hardware present
5795N/Aif [ "$BASEDIR" = "/" ]
5795N/Athen
5795N/A case ${hw_exists} in
5795N/A # On a running system with no hardware
5795N/A # modify the system files only
5795N/A 0) ADD_DRV="add_drv -n"
5795N/A ;;
5795N/A # On a running system with hardware
5795N/A # modify the system files and attach the driver
5795N/A 1) ADD_DRV="add_drv"
5795N/A ;;
5795N/A esac
4723N/Aelse
4133N/A # On a client
5795N/A # modify the sytem files and touch /reconfigure
4133N/A # for reconfigure reboot
4133N/A ADD_DRV="add_drv -b ${BASEDIR}"
4723N/Afi
5835N/A
5835N/AARCH=`uname -p`
4133N/Aif [ ${ARCH} = "i386" ]; then
4133N/A check_add_drv ${ADD_DRV} -i "'${DRVALIAS}'" ${DRV}
fi