1 #! /usr/bin/sh 2 # 3 # CDDL HEADER START 4 # 5 # The contents of this file are subject to the terms of the 6 # Common Development and Distribution License (the "License"). 7 # You may not use this file except in compliance with the License. 8 # 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 # or http://www.opensolaris.org/os/licensing. 11 # See the License for the specific language governing permissions 12 # and limitations under the License. 13 # 14 # When distributing Covered Code, include this CDDL HEADER in each 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 # If applicable, add the following below this CDDL HEADER, with the 17 # fields enclosed by brackets "[]" replaced with your own identifying 18 # information: Portions Copyright [yyyy] [name of copyright owner] 19 # 20 # CDDL HEADER END 21 # 22 23 # 24 # Copyright 2008 Sun Microsystems, Inc. All rights reserved. 25 # Use is subject to license terms. 26 # 27 28 # Driver info 29 DRV=ural 30 DRVALIAS='"usb1044,8007" "usb13b1,d" "usb411,67" "usb2001,3c00"' 31 32 BASEDIR=${BASEDIR:-/} 33 34 # Function: check_add_drv() 35 # 36 # This function will check if add_drv has been executed. 37 # If not simply calls add_drv. Otherwise adds entries to 38 # driver_aliases, driver_classes and minor_perm if necessary. 39 # The syntax of this function is the same as add_drv. 40 41 check_add_drv() 42 { 43 CMD="add_drv" 44 45 ALIAS="" 46 ALIASDIR="${BASEDIR}"/etc/driver_aliases 47 while getopts i:b: opt 2>/dev/null; do 48 case "$opt" in 49 i) CMD="${CMD} -i ${OPTARG}" 50 ALIAS=`echo ${OPTARG} | /usr/bin/sed -e "s/'//g"` 51 ;; 52 b) if [ "${OPTARG}" != "/" ]; then 53 # On a client 54 # modify the sytem files and touch 55 # /reconfigure for reconfigure reboot 56 CMD="${CMD} -b \"${OPTARG}\"" 57 fi 58 ;; 59 \?) echo "check_add_drv(): Unknown option $opt" 60 return 61 ;; 62 esac 63 done 64 shift `/usr/bin/expr ${OPTIND} - 1` 65 DRIVER=$1 66 CMD="${CMD} ${DRIVER}" 67 68 # Make sure add_drv has not been previously executed 69 # before attempting to add the driver 70 /usr/bin/egrep -s "^${DRIVER}[ ]" "$BASEDIR"/etc/name_to_major 71 72 if [ $? -ne 0 ]; then 73 eval ${CMD} 74 if [ $? -ne 0 ]; then 75 echo "Failed add_drv ${DRIVER}!\n" >&2 76 exit 1 77 fi 78 else 79 # Add driver entry if necessary 80 if [ -n "${ALIAS}" ]; then 81 for i in ${ALIAS}; do 82 /usr/bin/egrep -s "^${DRIVER}[ ]+$i" ${ALIASDIR} 83 if [ $? -ne 0 ]; then 84 echo "${DRIVER} $i" >> ${ALIASDIR} 85 fi 86 done 87 fi 88 fi 89 } 90 91 check_add_drv -b "${BASEDIR}" -i "'${DRVALIAS}'" ${DRV} 92