i.dhcpagent revision d04ccbb3f3163ae5962a8b7465d9796bff6ca434
#!/bin/sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% 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 <<EOF
# The default DHCPv6 parameter request list has preference (7), unicast (12),
# DNS addresses (23), DNS search list (24), NIS addresses (27), and
# NIS domain (29). This may be changed by altering the following parameter-
# value pair. The numbers correspond to the values defined in the IANA
# dhcpv6-parameters registry at the time of this writing.
.v6.PARAM_REQUEST_LIST=7,12,23,24,27,29
EOF
fi
done
exit 0