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, 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 (c) 2001 by Sun Microsystems, Inc.
     27 # All rights reserved.
     28 #
     29 
     30 PATH="/usr/bin:/usr/sbin:${PATH}"
     31 export PATH
     32 
     33 # During an upgrade this class action script merges user modifications in
     34 # the original ($dest) /etc/default/rpc.nisd into the new replacement
     35 # /etc/default/rpc.nisd ($src) file.
     36 #
     37 # If there is no existing default/rpc.nisd file, the script simply copies
     38 # the new default/rpc.nisd file into place. However, if there is an
     39 # existing default/rpc.nisd file, the script greps out each line which sets
     40 # a parameter in the original file and overwrites the corresponding line in
     41 # the new default/rpc.nisd file.
     42 #
     43 # The script works by looping through each variable name, grepping out the
     44 # apropos line, and creating a sed line, which when applied to the
     45 # replacement default/rpc.nisd file will preserve modifications in the
     46 # original default/rpc.nisd file.
     47 #
     48 
     49 while read src dest
     50 do
     51 	if [ ! -f $dest ] ; then
     52 		cp -p $src $dest
     53 	else
     54 		sedfile=/tmp/sftmp.$$
     55 		cat /dev/null > $sedfile
     56 
     57 		for word in nisplusNumberOfServiceThreads \
     58 		    nisplusMaxRPCRecordSize ENABLE_NIS_YP_EMULATION \
     59 		    nisplusThreadCreationErrorAction \
     60 		    nisplusThreadCreationErrorAttempts \
     61 		    nisplusThreadCreationErrorTimeout nisplusDumpErrorAction \
     62 		    nisplusDumpErrorAttempts nisplusDumpErrorTimeout \
     63 		    nisplusResyncService nisplusUpdateBatching \
     64 		    nisplusUpdateBatchingTimeout nisplusLDAPconfigDN \
     65 		    nisplusLDAPconfigPreferredServerList \
     66 		    nisplusLDAPconfigAuthenticationMethod nisplusLDAPconfigTLS \
     67 		    nisplusLDAPconfigTLSCertificateDBPath \
     68 		    nisplusLDAPconfigProxyUser nisplusLDAPconfigProxyPassword \
     69 		    preferredServerList authenticationMethod defaultSearchBase \
     70 		    nisplusLDAPbaseDomain nisplusLDAPTLS \
     71 		    nisplusLDAPTLSCertificateDBPath nisplusLDAPproxyUser \
     72 		    nisplusLDAPproxyPassword nisplusLDAPbindTimeout \
     73 		    nisplusLDAPsearchTimeout nisplusLDAPmodifyTimeout \
     74 		    nisplusLDAPaddTimeout nisplusLDAPdeleteTimeout \
     75 		    nisplusLDAPsearchTimeLimit nisplusLDAPsearchSizeLimit \
     76 		    nisplusLDAPfollowReferral nisplusLDAPinitialUpdateAction \
     77 		    nisplusLDAPinitialUpdateOnly \
     78 		    nisplusLDAPretrieveErrorAction \
     79 		    nisplusLDAPretrieveErrorAttempts \
     80 		    nisplusLDAPretrieveErrorTimeout \
     81 		    nisplusLDAPstoreErrorAction nisplusLDAPstoreErrorAttempts \
     82 		    nisplusLDAPstoreErrorTimeout nisplusLDAPrefreshErrorAction \
     83 		    nisplusLDAPrefreshErrorAttempts \
     84 		    nisplusLDAPrefreshErrorTimeout nisplusLDAPmatchFetchAction;
     85 		    do
     86 
     87 			oldline1=`grep -i "^$word=" $dest | \
     88 					tail -1 2> /dev/null`
     89 			oldline2=`grep -i "^#[ 	]*$word=" $dest | \
     90 					tail -1 2> /dev/null`
     91 
     92 			if [ -n "$oldline1" ]; then
     93 				echo "s|^[# 	]*$word=.*|$oldline1|" >> $sedfile
     94 			elif [ -n "$oldline2" ]; then
     95 				echo "s|^[# 	]*$word=.*|$oldline2|" >> $sedfile
     96 			fi
     97 
     98 		done
     99 		sed -f $sedfile $src > $dest 
    100 		rm -f $sedfile       
    101 
    102 	fi
    103 done
    104 
    105 exit 0
    106 
    107