Home | History | Annotate | Download | only in SUNWos86r
      1 #!/sbin/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 #ident	"%Z%%M%	%I%	%E% SMI"
     28 #
     29 
     30 #
     31 # postinstall script for SUNWos86r package.
     32 #
     33 	
     34 # check_add_drv() checks if the module has an entry in
     35 # etc/name_to_major.  If not, it simply calls add_drv with the arguments
     36 # given. If there is such an entry in name_to_major file, it adds
     37 # entries in driver_aliases driver_classes and minor_perm if necessary.
     38 # The syntax of this function is the same as add_drv.
     39 
     40 check_add_drv()
     41 {
     42 	basedir=/
     43 	alias=""
     44 	class=""
     45 	ADD_ALIAS=0
     46 	ADD_CLASS=0
     47 	ADD_MINOR=0
     48 	OPTIND=1
     49 	IS_NET_DRIVER=0
     50 
     51 	cmd="add_drv"
     52 
     53 	while getopts i:b:m:c:n  opt
     54 	do
     55 		case $opt in
     56 			i )	ADD_ALIAS=1	
     57 				alias=$OPTARG
     58 				cmd=$cmd" -i '$alias'"
     59 				;;
     60 			m )	ADD_MINOR=1
     61 				minor=$OPTARG
     62 				cmd=$cmd" -m '$minor'"
     63 				;;
     64 			c)	ADD_CLASS=1
     65 				class=$OPTARG
     66 				cmd=$cmd" -c $class"
     67 				;;
     68 			b)	basedir=$OPTARG
     69 				cmd=$cmd" -b $basedir"
     70 				;;
     71 			n)	IS_NET_DRIVER=1
     72 				;;
     73 			\?) 	echo "check_add_drv can not handle this option"
     74 				return
     75 				;;
     76 			esac
     77 	done 
     78 	shift `/usr/bin/expr $OPTIND - 1`
     79 	
     80 	drvname=$1
     81 
     82 	cmd=$cmd" "$drvname
     83 
     84 	drvname=`echo $drvname | /usr/bin/sed 's;.*/;;g'`
     85 
     86 	/usr/bin/grep "^$drvname[ 	]" $basedir/etc/name_to_major >  /dev/null 2>&1
     87 
     88 	if [ $? -ne 0 ] 
     89 	then
     90 		eval $cmd
     91 	else	
     92 		# entry already in name_to_major, add alias, class, minorperm
     93 		# if necessary
     94 		if [ $ADD_ALIAS = 1 ]	
     95 		then
     96 			for i in $alias
     97 			do
     98 				/usr/bin/egrep "^$drvname[ 	]+$i" $basedir/etc/driver_aliases>/dev/null 2>&1
     99 				if [ $? -ne 0 ]
    100 				then
    101 					echo "$drvname $i" >> $basedir/etc/driver_aliases	
    102 				fi
    103 			done
    104 		fi
    105 
    106 		if [ $ADD_CLASS = 1 ]
    107 		then
    108 			/usr/bin/egrep "^$drvname[ 	]+$class( |	|$)" $basedir/etc/driver_classes > /dev/null 2>&1
    109 			if [ $? -ne 0 ]
    110 			then 
    111 				echo "$drvname\t$class" >> $basedir/etc/driver_classes
    112 			fi
    113 		fi
    114 
    115 		if [ $ADD_MINOR = 1 ]
    116 		then
    117 			/usr/bin/grep "^$drvname:" $basedir/etc/minor_perm > /dev/null 2>&1
    118 			if [ $? -ne 0 ]
    119 			then 
    120 				minorentry="$drvname:$minor"
    121 				echo $minorentry >> $basedir/etc/minor_perm
    122 			fi
    123 		fi
    124 
    125 	fi
    126 
    127 	# The following clone device/dev is needed for Custom Jumpstart
    128 
    129 	if [ $IS_NET_DRIVER -eq 1 ]
    130 	then
    131 		CLONE_DEVICE=devices/pseudo/clone@0:$drvname
    132 		set `/usr/bin/grep "^clone[ 	]" $basedir/etc/name_to_major`
    133 		CLONE_MAJ=$2
    134 		set `/usr/bin/grep "^$drvname[ 	]" $basedir/etc/name_to_major`
    135 		DRIVER_MAJ=$2
    136 		mknod $basedir/$CLONE_DEVICE c $CLONE_MAJ $DRIVER_MAJ
    137 		chmod 600 $basedir/$CLONE_DEVICE
    138 		chgrp sys $basedir/$CLONE_DEVICE
    139 		chown root $basedir/$CLONE_DEVICE
    140 		ln -s ../$CLONE_DEVICE $basedir/dev/$drvname
    141 	fi
    142 	
    143 }
    144 
    145 
    146 # check_rem_drv() checks if the module has an entry in
    147 # etc/name_to_major.  If so, it simply calls rem_drv with the arguments
    148 # given to remove the driver from the system.  The syntax of this
    149 # function is the same as rem_drv.
    150 
    151 check_rem_drv()
    152 {
    153 	basedir=/
    154 	OPTIND=1
    155 
    156 	cmd="rem_drv"
    157 
    158 	while getopts b: opt
    159 	do
    160 		case $opt in
    161 			b)	basedir=$OPTARG
    162 				cmd=$cmd" -b $basedir"
    163 				;;
    164 			\?) 	echo "check_rem_drv can not handle this option"
    165 				return
    166 				;;
    167 			esac
    168 	done 
    169 	shift `/usr/bin/expr $OPTIND - 1`
    170 	
    171 	drvname=$1
    172 
    173 	cmd=$cmd" "$drvname
    174 
    175 	drvname=`echo $drvname | /usr/bin/sed 's;.*/;;g'`
    176 
    177 	/usr/bin/grep "^$drvname[ 	]" $basedir/etc/name_to_major >  /dev/null 2>&1
    178 
    179 	if [ $? -eq 0 ] 
    180 	then
    181 		eval $cmd
    182 	fi
    183 }
    184 
    185 
    186 # Platform-specific drivers
    187 case "${ARCH}" in
    188 i386)
    189 	check_add_drv -b "${BASEDIR}" \
    190 		-i '"pci1011,2" "pci1011,9" "pci1011,14" "pci1011,19"
    191 		"pci1109,1400" "pci1109,2400" "pci10b8,2001" "pci2646,1"' \
    192 		dnet
    193 	check_add_drv -b "${BASEDIR}" -i \
    194 		'"pci10b7,9000" "pci10b7,9001" "pci10b7,9004" "pci10b7,9005"
    195 		"pci10b7,9006" "pci10b7,9050" "pci10b7,9051" "pci10b7,9055"
    196 		"pci10b7,9056" "pci10b7,9200" "pci10b7,9800" "pci10b7,9805"' \
    197 		elxl
    198 	check_add_drv -b "${BASEDIR}" \
    199 		-i '"pci1022,2000" "pci103c,104c"' \
    200 		pcn
    201 	check_add_drv -b "${BASEDIR}" \
    202 		-i '"pci1011,21" "pci1014,22"' \
    203 		pci_pci
    204 	check_add_drv -b "${BASEDIR}" \
    205 		-c scsi \
    206 		-i '"pci1000,1" "pci1000,2" "pci1000,3" "pci1000,4"
    207 		"pci1000,6" "pci1000,c" "pci1000,f" "pci1000,8f" ' \
    208 		ncrs
    209 	check_add_drv -b "${BASEDIR}" \
    210 		-i '"pci8086,1029" "pci8086,1229" "pci8086,1229.8086.1009"
    211 		"pci8086,1229.8086.100c" "pci8086,1229.8086.1012"
    212 		"pci8086,1229.8086.1013" "pci8086,1229.8086.1015"
    213 		"pci8086,1229.8086.1016" "pci8086,1229.8086.1017"
    214 		"pci8086,1030" "pci8086,1031" "pci8086,1032" "pci8086,1038"
    215 		"pci8086,1039" "pci8086,103d" "pci8086,1050" "pci8086,1059"
    216 		"pci8086,1068" "pci8086,1069" "pci8086,1092" "pci8086,1209"
    217 		"pci8086,2449" "pci8086,27dc"' \
    218 		iprb
    219 	check_add_drv -b "${BASEDIR}" \
    220 		-i '"pci10b8,5"' \
    221 		spwr
    222 
    223 	# The sd driver should be installed to the system before rcs9.sh
    224 	# is called.
    225 	check_add_drv -b "${BASEDIR}" \
    226 		-m '* 0640 root sys' \
    227 		-i '"scsiclass,00" "scsiclass,05"' \
    228 		sd
    229 	
    230 	# Call the rcs9.sh script to update necessary files in case of upgrade
    231 	# for the PCI physical device pathname change from 2.4.
    232 	#
    233 	# Also used to preserve escd.rf (devconf configuration information)
    234 	# saved on floppy during an install boot.
    235 	#
    236 
    237 	if [ -s /tmp/diskette_rc.d/rcs9.sh ] 
    238 	then
    239 		/sbin/sh /tmp/diskette_rc.d/rcs9.sh "post"
    240 	fi
    241 	
    242 	#
    243 	# If there is no data in OWconfig, remove it.
    244 	#
    245 	OWC=/etc/openwin/server/etc/OWconfig
    246 	removef $PKGINST $OWC |\
    247 	while read pathname
    248 	do
    249 		if [ ! -s $pathname ]; then 
    250 			echo Removing empty `basename $pathname`
    251 			rm -f $pathname
    252 		fi
    253 	done	
    254 	removef -f $PKGINST
    255 
    256 	;;
    257 esac
    258 
    259 # Remove erroneous entry for Symbios Logic 53c875/95 (ncrs)
    260 TMPFILE=/tmp/ncrs_tmp
    261 sed -e '/^ncrs "pci1000,1000"$/d' ${BASEDIR}/etc/driver_aliases >$TMPFILE
    262 cp $TMPFILE ${BASEDIR}/etc/driver_aliases
    263 
    264 exit 0
    265