Home | History | Annotate | Download | only in common_files
      1 #!/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 #ident	"%Z%%M%	%I%	%E% SMI"
     28 
     29 PATH=/usr/bin:$PATH
     30 
     31 #
     32 # The IB Nexus driver (ib(7d)), requires the following lines :
     33 #       name="ib" class="root";
     34 # in /kernel/drv/ib.conf file.
     35 #
     36 # This script adds the required line and relevant comments,
     37 # if the lines are not already present in the ib.conf file.
     38 #
     39 
     40 #
     41 # Search for the line containing
     42 #	name="ib" class="root";
     43 # in ib.conf file. This returns 0 on a successful search.
     44 #
     45 search_ibconf()
     46 {
     47 	TGT_IBCONFFILE=$1
     48 
     49 	grep "$IB_SEARCH_STRING" $TGT_IBCONFFILE  > /dev/null 2>&1
     50 	search_result=$?
     51 	return $search_result
     52 }
     53 
     54 #
     55 # Update ib.conf just adds the line containing :
     56 #	name="ib" class="root";
     57 #    and the adjoining comments in target ib.conf file.
     58 #
     59 update_ibconf()
     60 {
     61 	TGT_IBCONFFILE=$2
     62 
     63 	echo $IB_STR1 >> $TGT_IBCONFFILE
     64 	echo $IB_STR2 >> $TGT_IBCONFFILE
     65 	echo $IB_STR3 >> $TGT_IBCONFFILE
     66 }
     67 
     68 #
     69 # Search Pattern and additional lines for ib.conf
     70 #
     71 IB_STR1="# The name and class property are required to indicate that IB nexus"
     72 IB_STR2="# driver is a child of the root nexus driver. DO NOT DELETE LINE BELOW"
     73 IB_STR3="name=\"ib\" class=\"root\";"
     74 IB_SEARCH_STRING="^[ 	]*name=\"ib\"[ 	]*class=\"root\"[ 	]*;"
     75 
     76 while read src dest; do
     77 	if [ -f $dest ]; then
     78 		#
     79 		# 1. Search the $dest file for relevant line 
     80 		# 2. If search fails, add the required lines to $dest
     81 		#
     82 		search_ibconf $dest
     83 		if [ "$?" -ne 0 ]; then
     84 			update_ibconf $src $dest
     85 		fi
     86 
     87 	else
     88 		#
     89 		# If no ib.conf file is present on the target system,
     90 		# just copy over the one from the package.
     91 		#
     92 		cp -p $src $dest
     93 	fi
     94 done
     95 exit 0
     96