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 # Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24 # Use is subject to license terms. 25 # 26 27 PATH="/usr/bin:/usr/sbin:${PATH}" 28 export PATH 29 30 while read src dest 31 do 32 if [ ! -f $dest ] ; then 33 cp $src $dest 34 else 35 # Carry on the CDDL header and comments stuff in $src 36 egrep '^#' $src > /tmp/i.$$ 37 38 SRC_DEVS=`awk '/^\/dev/ { print $1 }' $src` 39 for src_dev in $SRC_DEVS; do 40 # 41 # If $dest contains an entry that has the same device 42 # as $src_dev, copy the entry in $dest. 43 # Otherwise, copy the new one in $src. 44 # This loop maintains the device order in $src. 45 # 46 47 file=$src 48 egrep "^$src_dev" $dest > /dev/null && 49 file=$dest 50 51 egrep "^$src_dev" $file >> /tmp/i.$$ 52 done 53 54 DEST_DEVS=`awk '/^\/dev/ { print $1 }' $dest` 55 for dest_dev in $DEST_DEVS; do 56 # 57 # For entries that are not found in $src, 58 # append them to the target file. 59 # 60 egrep "^$dest_dev" /tmp/i.$$ > /dev/null || 61 egrep "^$dest_dev" $dest >> /tmp/i.$$ 62 done 63 64 mv /tmp/i.$$ $dest 65 fi 66 done 67 68 exit 0 69