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, Version 1.0 only 7 # (the "License"). You may not use this file except in compliance 8 # with the License. 9 # 10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11 # or http://www.opensolaris.org/os/licensing. 12 # See the License for the specific language governing permissions 13 # and limitations under the License. 14 # 15 # When distributing Covered Code, include this CDDL HEADER in each 16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17 # If applicable, add the following below this CDDL HEADER, with the 18 # fields enclosed by brackets "[]" replaced with your own identifying 19 # information: Portions Copyright [yyyy] [name of copyright owner] 20 # 21 # CDDL HEADER END 22 # 23 # 24 #ident "%Z%%M% %I% %E% SMI" 25 # 26 # Copyright 1999-2003 Sun Microsystems, Inc. All rights reserved. 27 # Use is subject to license terms. 28 # 29 30 write_comment() { 31 cat > /tmp/services.cmt.$$ << EOF 32 # 33 # The following customer-specific entries were found in the ${filename} file 34 # prior to an upgrade. Note that ${thing} names and their corresponding 35 # ${number} numbers must be registered with ${registrar}, ${regurl}, and 36 # entries not registered as such may not be preserved automatically by 37 # future upgrades. 38 # 39 EOF 40 } 41 42 while read src dest 43 do 44 if [ ! -f $dest ] ; then 45 cp $src $dest 46 else 47 48 # Adjust message as appropriate to target file. 49 50 d=`basename $dest` 51 52 # Assume english plural of word not ending in s. 53 # no need for heroic natural language processing, we can 54 # tweak things in the case statement below. 55 56 t=`basename $d s` 57 filename=${d} 58 thing=${t} 59 number=${t} 60 registrar=IANA 61 regurl=http://www.iana.org 62 63 # Override cases we know about. 64 case ${d} in 65 services) 66 number="port" 67 ;; 68 esac 69 70 grep -v "^#" $dest | \ 71 while read service port rest_of_line; do 72 grep "^$service[ ]*$port[ ]*" \ 73 $src > /dev/null 2>&1 74 if [ $? != 0 ]; then 75 # not in the new source 76 grep "^$service[ ]*$port[ ]*" \ 77 /tmp/services.$$ > /dev/null 2>&1 78 if [ $? != 0 ]; then 79 # also not a duplicate, get ONE line here 80 grep "^$service[ ]*$port[ ]*" \ 81 $dest | line >> /tmp/services.$$ 82 fi 83 fi 84 done 85 86 cat $src > /tmp/d.$$ 87 if [ -f /tmp/services.$$ ]; then 88 write_comment 89 cat /tmp/services.cmt.$$ >> /tmp/d.$$ 90 cat /tmp/services.$$ >> /tmp/d.$$ 91 rm -f /tmp/services.$$ /tmp/services.cmt.$$ 92 fi 93 cp /tmp/d.$$ $dest 94 rm -f /tmp/d.$$ 95 fi 96 done 97 98 exit 0 99