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 2007 Sun Microsystems, Inc. All rights reserved. 25 # Use is subject to license terms. 26 # 27 # ident "%Z%%M% %I% %E% SMI" 28 # 29 30 while read src dest 31 do 32 if [ ! -f $dest ] ; then 33 cp $src $dest 34 else 35 tmpdst=/var/run/dhcpagent.dst.$$ 36 37 # Changes are applied separately to accomodate user updates to 38 # the file. 39 40 # If the target has the old v4 comments, then update them 41 # to describe v6. 42 grep '# All parameters can be tuned for ' $dest >/dev/null && 43 ( grep '# An interface name alone ' $dest >/dev/null || ( 44 nawk ' 45 /# All parameters can be tuned for / { flag = 1; } 46 /^$/ && flag == 1 { 47 print "#"; 48 print "# An interface name alone specifies IPv4 DHCP. For DHCPv6, append \""\ 49 ".v6\"."; 50 print "# Some examples:"; 51 print "#"; 52 print "# hme0.RELEASE_ON_SIGTERM=no specify hme0 v4 behavior"; 53 print "# hme0.v6.RELEASE_ON_SIGTERM=no specify hme0 v6 behavior"; 54 print "# RELEASE_ON_SIGTERM=no match all v4 interfaces"; 55 print "# .v6.RELEASE_ON_SIGTERM=no match all v6 interfaces"; 56 flag = 2; 57 } 58 { print $0; } 59 ' $dest > $tmpdst && cp $tmpdst $dest 60 ) ) 61 62 # If the target has the old SIGTERM documentation, update. 63 if grep ' is sent a SIGTERM, all managed' $dest >/dev/null && 64 grep 'parameter-value pair, all managed' $dest >/dev/null 65 then 66 nawk ' 67 / is sent a SIGTERM, all managed/ { flag = 1; } 68 /parameter-value pair, all managed/ && flag == 1 { 69 print "# By default, when the DHCP agent is sent a SIGTERM (typically when"; 70 print "# the system is shut down), all managed addresses are dropped rather"; 71 print "# than released. Dropping an address does not notify the DHCP server"; 72 print "# that the address is no longer in use, leaving it possibly available"; 73 print "# for subsequent use by the same client. If DHCP is later restarted"; 74 print "# on the interface, the client will ask the server if it can continue"; 75 print "# to use the address. If the server either grants the request, or"; 76 print "# does not answer (and the lease has not yet expired), then the client"; 77 print "# will use the original address."; 78 print "#"; 79 print "# By uncommenting the following parameter-value pairs, all managed"; 80 print "# interfaces are released on SIGTERM instead. In that case, the DHCP"; 81 print "# server is notified that the address is available for use. Further,"; 82 print "# if DHCP is later restarted on the interface, the client will not"; 83 print "# request its previous address from the server, nor will it attempt to"; 84 print "# reuse the previous lease. This behavior is often preferred for"; 85 print "# roaming systems."; 86 flag = 2; 87 next; 88 } 89 flag == 1 { next; } 90 { print $0; } 91 ' $dest > $tmpdst && cp $tmpdst $dest 92 fi 93 94 # If the target lacks a v6 PARAM_REQUEST_LIST entry, then 95 # add it. 96 fgrep '.v6.PARAM_REQUEST_LIST' $dest >/dev/null || 97 cat >> $dest <<EOF 98 99 # The default DHCPv6 parameter request list has preference (7), unicast (12), 100 # DNS addresses (23), DNS search list (24), NIS addresses (27), and 101 # NIS domain (29). This may be changed by altering the following parameter- 102 # value pair. The numbers correspond to the values defined in the IANA 103 # dhcpv6-parameters registry at the time of this writing. 104 .v6.PARAM_REQUEST_LIST=7,12,23,24,27,29 105 EOF 106 fi 107 done 108 exit 0 109