postinstall revision 5644143a6cf1e70bc2e78d5140970830aae0e8cd
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#! /usr/bin/sh
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# CDDL HEADER START
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# The contents of this file are subject to the terms of the
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# Common Development and Distribution License (the "License").
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# You may not use this file except in compliance with the License.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# or http://www.opensolaris.org/os/licensing.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# See the License for the specific language governing permissions
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov# and limitations under the License.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov# When distributing Covered Code, include this CDDL HEADER in each
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# If applicable, add the following below this CDDL HEADER, with the
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov# fields enclosed by brackets "[]" replaced with your own identifying
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# information: Portions Copyright [yyyy] [name of copyright owner]
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov#
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# CDDL HEADER END
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov#
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov# Use is subject to license terms.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov# Driver info
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweDRV=ural
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri PankovDRVALIAS='"usb1044,8007" "usb13b1,d" "usb411,67" "usb2001,3c00"'
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweBASEDIR=${BASEDIR:-/}
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov# Function: check_add_drv()
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov# This function will check if add_drv has been executed.
# If not simply calls add_drv. Otherwise adds entries to
# driver_aliases, driver_classes and minor_perm if necessary.
# The syntax of this function is the same as add_drv.
check_add_drv()
{
CMD="add_drv"
ALIAS=""
ALIASDIR="${BASEDIR}"/etc/driver_aliases
while getopts i:b: opt 2>/dev/null; do
case "$opt" in
i) CMD="${CMD} -i ${OPTARG}"
ALIAS=`echo ${OPTARG} | /usr/bin/sed -e "s/'//g"`
;;
b) if [ "${OPTARG}" != "/" ]; then
# On a client
# modify the sytem files and touch
# /reconfigure for reconfigure reboot
CMD="${CMD} -b \"${OPTARG}\""
fi
;;
\?) echo "check_add_drv(): Unknown option $opt"
return
;;
esac
done
shift `/usr/bin/expr ${OPTIND} - 1`
DRIVER=$1
CMD="${CMD} ${DRIVER}"
# Make sure add_drv has not been previously executed
# before attempting to add the driver
/usr/bin/egrep -s "^${DRIVER}[ ]" "$BASEDIR"/etc/name_to_major
if [ $? -ne 0 ]; then
eval ${CMD}
if [ $? -ne 0 ]; then
echo "Failed add_drv ${DRIVER}!\n" >&2
exit 1
fi
else
# Add driver entry if necessary
if [ -n "${ALIAS}" ]; then
for i in ${ALIAS}; do
/usr/bin/egrep -s "^${DRIVER}[ ]+$i" ${ALIASDIR}
if [ $? -ne 0 ]; then
echo "${DRIVER} $i" >> ${ALIASDIR}
fi
done
fi
fi
}
check_add_drv -b "${BASEDIR}" -i "'${DRVALIAS}'" ${DRV}