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