#!/bin/sh # # Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "@(#)i.dhcpagent 1.1 07/01/29 SMI" # while read src dest do if [ ! -f $dest ] ; then cp $src $dest else tmpdst=/var/run/dhcpagent.dst.$$ # Changes are applied separately to accomodate user updates to # the file. # If the target has the old v4 comments, then update them # to describe v6. grep '# All parameters can be tuned for ' $dest >/dev/null && ( grep '# An interface name alone ' $dest >/dev/null || ( nawk ' /# All parameters can be tuned for / { flag = 1; } /^$/ && flag == 1 { print "#"; print "# An interface name alone specifies IPv4 DHCP. For DHCPv6, append \""\ ".v6\"."; print "# Some examples:"; print "#"; print "# hme0.RELEASE_ON_SIGTERM=no specify hme0 v4 behavior"; print "# hme0.v6.RELEASE_ON_SIGTERM=no specify hme0 v6 behavior"; print "# RELEASE_ON_SIGTERM=no match all v4 interfaces"; print "# .v6.RELEASE_ON_SIGTERM=no match all v6 interfaces"; flag = 2; } { print $0; } ' $dest > $tmpdst && cp $tmpdst $dest ) ) # If the target has the old SIGTERM documentation, update. if grep ' is sent a SIGTERM, all managed' $dest >/dev/null && grep 'parameter-value pair, all managed' $dest >/dev/null then nawk ' / is sent a SIGTERM, all managed/ { flag = 1; } /parameter-value pair, all managed/ && flag == 1 { print "# By default, when the DHCP agent is sent a SIGTERM (typically when"; print "# the system is shut down), all managed addresses are dropped rather"; print "# than released. Dropping an address does not notify the DHCP server"; print "# that the address is no longer in use, leaving it possibly available"; print "# for subsequent use by the same client. If DHCP is later restarted"; print "# on the interface, the client will ask the server if it can continue"; print "# to use the address. If the server either grants the request, or"; print "# does not answer (and the lease has not yet expired), then the client"; print "# will use the original address."; print "#"; print "# By uncommenting the following parameter-value pairs, all managed"; print "# interfaces are released on SIGTERM instead. In that case, the DHCP"; print "# server is notified that the address is available for use. Further,"; print "# if DHCP is later restarted on the interface, the client will not"; print "# request its previous address from the server, nor will it attempt to"; print "# reuse the previous lease. This behavior is often preferred for"; print "# roaming systems."; flag = 2; next; } flag == 1 { next; } { print $0; } ' $dest > $tmpdst && cp $tmpdst $dest fi # If the target lacks a v6 PARAM_REQUEST_LIST entry, then # add it. fgrep '.v6.PARAM_REQUEST_LIST' $dest >/dev/null || cat >> $dest <