i.dhcpagent revision d04ccbb3f3163ae5962a8b7465d9796bff6ca434
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor#!/bin/sh
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor#
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd# CDDL HEADER START
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd#
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd# The contents of this file are subject to the terms of the
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor# Common Development and Distribution License (the "License").
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor# You may not use this file except in compliance with the License.
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor#
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
96ad5d81ee4a2cc66a4ae19893efc8aa6d06fae7jailletc# or http://www.opensolaris.org/os/licensing.
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor# See the License for the specific language governing permissions
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor# and limitations under the License.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen#
2e545ce2450a9953665f701bb05350f0d3f26275nd# When distributing Covered Code, include this CDDL HEADER in each
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen# If applicable, add the following below this CDDL HEADER, with the
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor# fields enclosed by brackets "[]" replaced with your own identifying
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor# information: Portions Copyright [yyyy] [name of copyright owner]
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor#
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen# CDDL HEADER END
3f08db06526d6901aa08c110b5bc7dde6bc39905nd#
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor#
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
3f08db06526d6901aa08c110b5bc7dde6bc39905nd# Use is subject to license terms.
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor#
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor# ident "%Z%%M% %I% %E% SMI"
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor#
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjungwhile read src dest
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzordo
f5743872325117317b6a64c3e49a5f9bb3d49ffcrbowen if [ ! -f $dest ] ; then
f5743872325117317b6a64c3e49a5f9bb3d49ffcrbowen cp $src $dest
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor else
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor tmpdst=/var/run/dhcpagent.dst.$$
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor # Changes are applied separately to accomodate user updates to
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor # the file.
c867dba1041640ecec7c8194d35a5b4ffce442earbowen
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor # If the target has the old v4 comments, then update them
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor # to describe v6.
c867dba1041640ecec7c8194d35a5b4ffce442earbowen grep '# All parameters can be tuned for ' $dest >/dev/null &&
c867dba1041640ecec7c8194d35a5b4ffce442earbowen ( grep '# An interface name alone ' $dest >/dev/null || (
b71e5eae594d54e9e56dc20208c6a7fb52610e29rbowen nawk '
c867dba1041640ecec7c8194d35a5b4ffce442earbowen /# All parameters can be tuned for / { flag = 1; }
c867dba1041640ecec7c8194d35a5b4ffce442earbowen /^$/ && flag == 1 {
c867dba1041640ecec7c8194d35a5b4ffce442earbowenprint "#";
c867dba1041640ecec7c8194d35a5b4ffce442earbowenprint "# An interface name alone specifies IPv4 DHCP. For DHCPv6, append \""\
c867dba1041640ecec7c8194d35a5b4ffce442earbowen ".v6\".";
c867dba1041640ecec7c8194d35a5b4ffce442earbowenprint "# Some examples:";
c867dba1041640ecec7c8194d35a5b4ffce442earbowenprint "#";
c867dba1041640ecec7c8194d35a5b4ffce442earbowenprint "# hme0.RELEASE_ON_SIGTERM=no specify hme0 v4 behavior";
c867dba1041640ecec7c8194d35a5b4ffce442earbowenprint "# hme0.v6.RELEASE_ON_SIGTERM=no specify hme0 v6 behavior";
c867dba1041640ecec7c8194d35a5b4ffce442earbowenprint "# RELEASE_ON_SIGTERM=no match all v4 interfaces";
c867dba1041640ecec7c8194d35a5b4ffce442earbowenprint "# .v6.RELEASE_ON_SIGTERM=no match all v6 interfaces";
c867dba1041640ecec7c8194d35a5b4ffce442earbowen flag = 2;
c867dba1041640ecec7c8194d35a5b4ffce442earbowen }
c867dba1041640ecec7c8194d35a5b4ffce442earbowen { print $0; }
c867dba1041640ecec7c8194d35a5b4ffce442earbowen ' $dest > $tmpdst && cp $tmpdst $dest
c867dba1041640ecec7c8194d35a5b4ffce442earbowen ) )
c867dba1041640ecec7c8194d35a5b4ffce442earbowen
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor # If the target has the old SIGTERM documentation, update.
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor if grep ' is sent a SIGTERM, all managed' $dest >/dev/null &&
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor grep 'parameter-value pair, all managed' $dest >/dev/null
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor then
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor nawk '
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzor / is sent a SIGTERM, all managed/ { flag = 1; }
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar /parameter-value pair, all managed/ && flag == 1 {
1f1b6bf13313fdd14a45e52e553d3ff28689b717coarprint "# By default, when the DHCP agent is sent a SIGTERM (typically when";
1f1b6bf13313fdd14a45e52e553d3ff28689b717coarprint "# the system is shut down), all managed addresses are dropped rather";
1f1b6bf13313fdd14a45e52e553d3ff28689b717coarprint "# than released. Dropping an address does not notify the DHCP server";
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzorprint "# that the address is no longer in use, leaving it possibly available";
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzorprint "# for subsequent use by the same client. If DHCP is later restarted";
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzorprint "# on the interface, the client will ask the server if it can continue";
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzorprint "# to use the address. If the server either grants the request, or";
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzorprint "# does not answer (and the lease has not yet expired), then the client";
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzorprint "# will use the original address.";
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzorprint "#";
dc3a272f8afcbc137adcfee4c3aa052d2bdf4df7gryzorprint "# By uncommenting the following parameter-value pairs, all managed";
1f1b6bf13313fdd14a45e52e553d3ff28689b717coarprint "# interfaces are released on SIGTERM instead. In that case, the DHCP";
1f1b6bf13313fdd14a45e52e553d3ff28689b717coarprint "# server is notified that the address is available for use. Further,";
1f1b6bf13313fdd14a45e52e553d3ff28689b717coarprint "# if DHCP is later restarted on the interface, the client will not";
1f1b6bf13313fdd14a45e52e553d3ff28689b717coarprint "# request its previous address from the server, nor will it attempt to";
1f1b6bf13313fdd14a45e52e553d3ff28689b717coarprint "# reuse the previous lease. This behavior is often preferred for";
1f1b6bf13313fdd14a45e52e553d3ff28689b717coarprint "# roaming systems.";
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar flag = 2;
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar next;
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar }
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar flag == 1 { next; }
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar { print $0; }
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar ' $dest > $tmpdst && cp $tmpdst $dest
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar fi
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar # If the target lacks a v6 PARAM_REQUEST_LIST entry, then
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar # add it.
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar fgrep '.v6.PARAM_REQUEST_LIST' $dest >/dev/null ||
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar cat >> $dest <<EOF
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar# The default DHCPv6 parameter request list has preference (7), unicast (12),
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar# DNS addresses (23), DNS search list (24), NIS addresses (27), and
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar# NIS domain (29). This may be changed by altering the following parameter-
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar# value pair. The numbers correspond to the values defined in the IANA
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar# dhcpv6-parameters registry at the time of this writing.
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar.v6.PARAM_REQUEST_LIST=7,12,23,24,27,29
1f1b6bf13313fdd14a45e52e553d3ff28689b717coarEOF
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar fi
1f1b6bf13313fdd14a45e52e553d3ff28689b717coardone
1f1b6bf13313fdd14a45e52e553d3ff28689b717coarexit 0
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar