head	1.14;
access;
symbols
	perseant-exfatfs-base-20250801:1.14
	perseant-exfatfs-base-20240630:1.14
	perseant-exfatfs:1.14.0.18
	perseant-exfatfs-base:1.14
	cjep_sun2x:1.14.0.16
	cjep_sun2x-base:1.14
	cjep_staticlib_x-base1:1.14
	cjep_staticlib_x:1.14.0.14
	cjep_staticlib_x-base:1.14
	phil-wifi-20200421:1.14
	phil-wifi-20200411:1.14
	phil-wifi-20200406:1.14
	pgoyette-compat-merge-20190127:1.14
	pgoyette-compat-20190127:1.14
	pgoyette-compat-20190118:1.14
	pgoyette-compat-1226:1.14
	pgoyette-compat-1126:1.14
	pgoyette-compat-1020:1.14
	pgoyette-compat-0930:1.14
	pgoyette-compat-0906:1.14
	pgoyette-compat-0728:1.14
	pgoyette-compat-0625:1.14
	pgoyette-compat-0521:1.14
	pgoyette-compat-0502:1.14
	pgoyette-compat-0422:1.14
	pgoyette-compat-0415:1.14
	pgoyette-compat-0407:1.14
	pgoyette-compat-0330:1.14
	pgoyette-compat-0322:1.14
	pgoyette-compat-0315:1.14
	pgoyette-compat:1.14.0.12
	pgoyette-compat-base:1.14
	perseant-stdc-iso10646:1.14.0.10
	perseant-stdc-iso10646-base:1.14
	prg-localcount2-base3:1.14
	prg-localcount2-base2:1.14
	prg-localcount2-base1:1.14
	prg-localcount2:1.14.0.8
	prg-localcount2-base:1.14
	pgoyette-localcount-20170426:1.14
	bouyer-socketcan-base1:1.14
	pgoyette-localcount-20170320:1.14
	bouyer-socketcan:1.14.0.6
	bouyer-socketcan-base:1.14
	pgoyette-localcount-20170107:1.14
	pgoyette-localcount-20161104:1.14
	localcount-20160914:1.14
	pgoyette-localcount-20160806:1.14
	pgoyette-localcount-20160726:1.14
	pgoyette-localcount:1.14.0.4
	pgoyette-localcount-base:1.14
	netbsd-5-2-3-RELEASE:1.12
	netbsd-5-1-5-RELEASE:1.12
	netbsd-6-0-6-RELEASE:1.13
	netbsd-6-1-5-RELEASE:1.13
	yamt-pagecache-base9:1.14
	yamt-pagecache-tag8:1.13
	netbsd-6-1-4-RELEASE:1.13
	netbsd-6-0-5-RELEASE:1.13
	tls-earlyentropy:1.14.0.2
	tls-earlyentropy-base:1.14
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.14
	riastradh-drm2-base3:1.14
	netbsd-6-1-3-RELEASE:1.13
	netbsd-6-0-4-RELEASE:1.13
	netbsd-5-2-2-RELEASE:1.12
	netbsd-5-1-4-RELEASE:1.12
	netbsd-6-1-2-RELEASE:1.13
	netbsd-6-0-3-RELEASE:1.13
	netbsd-5-2-1-RELEASE:1.12
	netbsd-5-1-3-RELEASE:1.12
	netbsd-6-1-1-RELEASE:1.13
	netbsd-6-1:1.13.0.20
	netbsd-6-0-2-RELEASE:1.13
	netbsd-6-1-RELEASE:1.13
	netbsd-6-1-RC4:1.13
	netbsd-6-1-RC3:1.13
	agc-symver:1.13.0.18
	agc-symver-base:1.13
	netbsd-6-1-RC2:1.13
	netbsd-6-1-RC1:1.13
	yamt-pagecache-base8:1.13
	netbsd-5-2:1.12.0.36
	netbsd-6-0-1-RELEASE:1.13
	yamt-pagecache-base7:1.13
	netbsd-5-2-RELEASE:1.12
	netbsd-5-2-RC1:1.12
	matt-nb6-plus-nbase:1.13
	yamt-pagecache-base6:1.13
	netbsd-6-0:1.13.0.14
	netbsd-6-0-RELEASE:1.13
	netbsd-6-0-RC2:1.13
	tls-maxphys:1.13.0.12
	tls-maxphys-base:1.14
	matt-nb6-plus:1.13.0.10
	matt-nb6-plus-base:1.13
	netbsd-6-0-RC1:1.13
	yamt-pagecache-base5:1.13
	yamt-pagecache-base4:1.13
	netbsd-6:1.13.0.8
	netbsd-6-base:1.13
	netbsd-5-1-2-RELEASE:1.12
	netbsd-5-1-1-RELEASE:1.12
	yamt-pagecache-base3:1.13
	yamt-pagecache-base2:1.13
	yamt-pagecache:1.13.0.6
	yamt-pagecache-base:1.13
	cherry-xenmp:1.13.0.4
	cherry-xenmp-base:1.13
	bouyer-quota2-nbase:1.13
	bouyer-quota2:1.13.0.2
	bouyer-quota2-base:1.13
	matt-mips64-premerge-20101231:1.13
	matt-nb5-mips64-premerge-20101231:1.12
	matt-nb5-pq3:1.12.0.34
	matt-nb5-pq3-base:1.12
	netbsd-5-1:1.12.0.32
	netbsd-5-1-RELEASE:1.12
	netbsd-5-1-RC4:1.12
	matt-nb5-mips64-k15:1.12
	netbsd-5-1-RC3:1.12
	netbsd-5-1-RC2:1.12
	netbsd-5-1-RC1:1.12
	netbsd-5-0-2-RELEASE:1.12
	matt-nb5-mips64-premerge-20091211:1.12
	matt-premerge-20091211:1.13
	matt-nb5-mips64-u2-k2-k4-k7-k8-k9:1.12
	matt-nb4-mips64-k7-u2a-k9b:1.12
	matt-nb5-mips64-u1-k1-k5:1.12
	matt-nb5-mips64:1.12.0.30
	netbsd-5-0-1-RELEASE:1.12
	jym-xensuspend-nbase:1.12
	netbsd-5-0:1.12.0.28
	netbsd-5-0-RELEASE:1.12
	netbsd-5-0-RC4:1.12
	netbsd-5-0-RC3:1.12
	netbsd-5-0-RC2:1.12
	jym-xensuspend:1.12.0.26
	jym-xensuspend-base:1.12
	netbsd-5-0-RC1:1.12
	netbsd-5:1.12.0.24
	netbsd-5-base:1.12
	matt-mips64-base2:1.12
	matt-mips64:1.12.0.22
	mjf-devfs2:1.12.0.20
	mjf-devfs2-base:1.12
	netbsd-4-0-1-RELEASE:1.12
	wrstuden-revivesa-base-3:1.12
	wrstuden-revivesa-base-2:1.12
	wrstuden-fixsa-newbase:1.12
	wrstuden-revivesa-base-1:1.12
	yamt-pf42-base4:1.12
	yamt-pf42-base3:1.12
	hpcarm-cleanup-nbase:1.12
	yamt-pf42-baseX:1.12
	yamt-pf42-base2:1.12
	wrstuden-revivesa:1.12.0.18
	wrstuden-revivesa-base:1.12
	yamt-pf42:1.12.0.16
	yamt-pf42-base:1.12
	keiichi-mipv6-nbase:1.12
	keiichi-mipv6:1.12.0.14
	keiichi-mipv6-base:1.12
	matt-armv6-nbase:1.12
	matt-armv6-prevmlocking:1.12
	wrstuden-fixsa-base-1:1.12
	netbsd-4-0:1.12.0.12
	netbsd-4-0-RELEASE:1.12
	cube-autoconf:1.12.0.10
	cube-autoconf-base:1.12
	netbsd-4-0-RC5:1.12
	netbsd-4-0-RC4:1.12
	netbsd-4-0-RC3:1.12
	netbsd-4-0-RC2:1.12
	netbsd-4-0-RC1:1.12
	matt-armv6:1.12.0.8
	matt-armv6-base:1.12
	matt-mips64-base:1.12
	hpcarm-cleanup:1.12.0.6
	hpcarm-cleanup-base:1.12
	netbsd-3-1-1-RELEASE:1.6.2.1
	netbsd-3-0-3-RELEASE:1.6
	wrstuden-fixsa:1.12.0.4
	wrstuden-fixsa-base:1.12
	abandoned-netbsd-4-base:1.10
	abandoned-netbsd-4:1.10.0.2
	netbsd-3-1:1.6.2.1.0.2
	netbsd-3-1-RELEASE:1.6.2.1
	netbsd-3-0-2-RELEASE:1.6
	netbsd-3-1-RC4:1.6
	netbsd-3-1-RC3:1.6
	netbsd-3-1-RC2:1.6
	netbsd-3-1-RC1:1.6
	netbsd-4:1.12.0.2
	netbsd-4-base:1.12
	netbsd-3-0-1-RELEASE:1.6
	netbsd-3-0:1.6.0.4
	netbsd-3-0-RELEASE:1.6
	netbsd-3-0-RC6:1.6
	netbsd-3-0-RC5:1.6
	netbsd-3-0-RC4:1.6
	netbsd-3-0-RC3:1.6
	netbsd-3-0-RC2:1.6
	netbsd-3-0-RC1:1.6
	netbsd-2-0-3-RELEASE:1.5
	netbsd-2-1:1.5.0.6
	netbsd-2-1-RELEASE:1.5
	netbsd-2-1-RC6:1.5
	netbsd-2-1-RC5:1.5
	netbsd-2-1-RC4:1.5
	netbsd-2-1-RC3:1.5
	netbsd-2-1-RC2:1.5
	netbsd-2-1-RC1:1.5
	netbsd-2-0-2-RELEASE:1.5
	netbsd-3:1.6.0.2
	netbsd-3-base:1.6
	netbsd-2-0-1-RELEASE:1.5
	netbsd-2:1.5.0.4
	netbsd-2-base:1.5
	netbsd-2-0-RELEASE:1.5
	netbsd-2-0-RC5:1.5
	netbsd-2-0-RC4:1.5
	netbsd-2-0-RC3:1.5
	netbsd-2-0-RC2:1.5
	netbsd-2-0-RC1:1.5
	netbsd-2-0:1.5.0.2
	netbsd-2-0-base:1.5
	netbsd-1-6-PATCH002-RELEASE:1.4
	netbsd-1-6-PATCH002:1.4
	netbsd-1-6-PATCH002-RC4:1.4
	netbsd-1-6-PATCH002-RC3:1.4
	netbsd-1-6-PATCH002-RC2:1.4
	netbsd-1-6-PATCH002-RC1:1.4
	netbsd-1-6-PATCH001:1.4
	netbsd-1-6-PATCH001-RELEASE:1.4
	netbsd-1-6-PATCH001-RC3:1.4
	netbsd-1-6-PATCH001-RC2:1.4
	netbsd-1-6-PATCH001-RC1:1.4
	fvdl_fs64_base:1.5
	netbsd-1-6-RELEASE:1.4
	netbsd-1-6-RC3:1.4
	netbsd-1-6-RC2:1.4
	netbsd-1-6-RC1:1.4
	netbsd-1-6:1.4.0.2
	netbsd-1-6-base:1.4
	netbsd-1-5-PATCH003:1.1.2.2
	netbsd-1-5-PATCH002:1.1.2.2
	netbsd-1-5:1.1.0.2;
locks; strict;
comment	@# @;


1.14
date	2013.06.20.18.41.26;	author christos;	state dead;
branches;
next	1.13;
commitid	1DeRCJ1NyAipTnUw;

1.13
date	2009.11.21.07.53.59;	author roy;	state Exp;
branches
	1.13.6.1
	1.13.12.1;
next	1.12;

1.12
date	2006.10.08.17.09.32;	author riz;	state Exp;
branches;
next	1.11;

1.11
date	2006.09.23.22.54.43;	author dyoung;	state Exp;
branches;
next	1.10;

1.10
date	2006.07.10.23.07.09;	author christos;	state Exp;
branches;
next	1.9;

1.9
date	2005.07.16.08.41.27;	author rtr;	state Exp;
branches;
next	1.8;

1.8
date	2005.06.19.05.04.34;	author blymn;	state Exp;
branches;
next	1.7;

1.7
date	2005.04.09.02.14.52;	author atatat;	state Exp;
branches;
next	1.6;

1.6
date	2004.10.04.12.54.06;	author grant;	state Exp;
branches
	1.6.2.1;
next	1.5;

1.5
date	2002.05.28.15.04.01;	author christos;	state Exp;
branches;
next	1.4;

1.4
date	2002.04.10.10.11.41;	author enami;	state Exp;
branches
	1.4.2.1;
next	1.3;

1.3
date	2002.04.02.19.16.59;	author christos;	state Exp;
branches;
next	1.2;

1.2
date	2002.04.02.17.39.47;	author christos;	state Exp;
branches;
next	1.1;

1.1
date	2001.08.03.14.30.19;	author drochner;	state Exp;
branches
	1.1.2.1;
next	;

1.13.6.1
date	2014.05.22.11.43.02;	author yamt;	state dead;
branches;
next	;
commitid	wmvImESqVQCgMwBx;

1.13.12.1
date	2013.06.23.06.29.03;	author tls;	state dead;
branches;
next	;
commitid	OnlO1cBgtQRcIHUw;

1.6.2.1
date	2006.10.16.20.39.36;	author ghen;	state Exp;
branches;
next	;

1.4.2.1
date	2004.03.12.05.23.55;	author jmc;	state Exp;
branches;
next	;

1.1.2.1
date	2001.08.03.14.30.19;	author tv;	state dead;
branches;
next	1.1.2.2;

1.1.2.2
date	2001.08.16.18.53.28;	author tv;	state Exp;
branches;
next	;


desc
@@


1.14
log
@bye build glue
@
text
@#!/bin/sh
#
# $NetBSD: dhclient-script,v 1.13 2009/11/21 07:53:59 roy Exp $

ENTERHOOKS=/etc/dhclient-enter-hooks
EXITHOOKS=/etc/dhclient-exit-hooks
RESOLV=/etc/resolv.conf
SIGNATURE="# Created by dhclient from"
INTSIG="$SIGNATURE $interface"

echo_resolv_conf() {
	echo "$INTSIG"
	echo search $new_domain_name
	for nameserver in $new_domain_name_servers; do
		echo nameserver $nameserver
	done
}

make_resolv_conf() {
	if [ ! -z "$new_domain_name_servers" ]; then
		if [ -x /sbin/resolvconf ]; then
			echo_resolv_conf | /sbin/resolvconf -a $interface
		else
			if [ -f $RESOLV ]; then
				while read line; do
					case $line in
					"$SIGNATURE"*)
						;;
					*)
						mv $RESOLV $RESOLV.save;;
					esac
					break
				done < $RESOLV
			fi
			echo_resolv_conf > $RESOLV
		fi
	fi
}

restore_resolv_conf() {
	if [ -x /sbin/resolvconf ]; then
		/sbin/resolvconf -d $interface
	elif [ -f $RESOLV.save -a -f $RESOLV ]; then
		while read line; do
			case $line in
			"$INTSIG"*)
				mv $RESOLV.save $RESOLV;;
			esac
			break
		done < $RESOLV
	fi
}

# Must be used on exit.   Invokes the local dhcp client exit hooks, if any.
exit_with_hooks() {
	exit_status=$1
	if [ -f "$EXITHOOKS" ]; then
		. "$EXITHOOKS"
	fi
	# probably should do something with exit status of the local script
	exit $exit_status
}


add_new_routes() {
	for router in $new_routers; do
		route add default $router
	done >/dev/null 2>&1

	set -- $new_static_routes
	while [ $# -gt 1 ]; do
		route add $1 $2
		shift; shift
	done
}

delete_old_routes() {
	for router in $old_routers; do
		route delete default $router
	done >/dev/null 2>&1

	set -- $old_static_routes
	while [ $# -gt 1 ]; do
		route delete $1 $2
		shift; shift
	done

	route -n flush -inet -llinfo -host
}

# Invoke the local dhcp client enter hooks, if they exist.
if [ -f $ENTERHOOKS ]; then
	exit_status=0
	. $ENTERHOOKS
	# allow the local script to abort processing of this state
	# local script must set exit_status variable to nonzero.
	if [ $exit_status -ne 0 ]; then
		exit $exit_status
	fi
fi

#if [ ! -z "$new_host_name" ]; then
#	echo New Host Name: $new_host_name
#fi
#
#if [ ! -z "$new_nis_domain" ]; then
#	echo New NIS Domain: $new_nis_domain
#fi
#
#if [ ! -z "$new_network_number" ]; then
#	echo New Network Number: $new_network_number
#fi

if [ ! -z "$new_broadcast_address" ]; then
#	echo New Broadcast Address: $new_broadcast_address
	new_broadcast_arg="broadcast $new_broadcast_address"
fi

if [ ! -z "$old_broadcast_address" ]; then
	old_broadcast_arg="broadcast $old_broadcast_address"
fi

if [ ! -z "$new_subnet_mask" ]; then
	new_netmask_arg="netmask $new_subnet_mask"
fi

if [ ! -z "$old_subnet_mask" ]; then
	old_netmask_arg="netmask $old_subnet_mask"
fi

if [ ! -z "$alias_subnet_mask" ]; then
	alias_subnet_arg="netmask $alias_subnet_mask"
fi

case "$reason" in
MEDIUM)
	test -z "$medium" && exit_with_hooks 0
	eval "ifconfig $interface $medium"
	eval "ifconfig $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1

	sleep 1

	exit_with_hooks 0
	;;

PREINIT)
	if [ ! -z "$alias_ip_address" ]; then
		ifconfig $interface inet \
		    -alias $alias_ip_address >/dev/null 2>&1
		route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
	fi

	ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
	    broadcast 255.255.255.255 up

	exit_with_hooks 0
	;;

ARPCHECK|ARPSEND)
	exit_with_hooks 0
	;;

BOUND|RENEW|REBIND|REBOOT)
	if [ ! -z "$new_nis_domain" ]; then
		if type domainname > /dev/null 2>&1; then
			domainname $new_nis_domain
		fi
	fi

	if type hostname > /dev/null 2>&1; then
		if [ \( -z "$current_hostname" \) -o \
		    \( "x$new_host_name" = "x$old_hostname" \) ]; then
			current_hostname=`hostname`
		fi
		if [ \( -z "$current_hostname" \) -o \
		    \( "x$new_host_name" != "x$old_hostname" \) ]; then
			hostname $new_host_name
		fi
	fi
    
	if [ \( ! -z "$old_ip_address" \) -a \( ! -z "$alias_ip_address" \) -a \
	    \( "x$alias_ip_address" != "x$old_ip_address" \) ]; then
		ifconfig $interface inet \
		    -alias $alias_ip_address > /dev/null 2>&1
		route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
	fi

	if [ \( ! -z "$old_ip_address" \) -a \
	    \( "x$old_ip_address" != "x$new_ip_address" \) ]; then
		eval "ifconfig $interface inet -alias $old_ip_address $medium"
		route delete $old_ip_address 127.0.0.1 >/dev/null 2>&1

		delete_old_routes
	fi

	if [ \( -z "$old_ip_address" \) -o \
	    \( "x$old_ip_address" != "x$new_ip_address" \) -o \
	    \( "x$reason" = "xBOUND" \) -o \( "x$reason" = "xREBOOT" \) ]; then
		eval "ifconfig $interface inet $new_ip_address \
		    $new_netmask_arg $new_broadcast_arg $medium"
		route add $new_ip_address 127.0.0.1 >/dev/null 2>&1

		add_new_routes
	fi

	if [ \( ! -z "$alias_ip_address" \) -a \
	    \( "x$new_ip_address" != "x$alias_ip_address" \) ]; then
		ifconfig $interface inet alias $alias_ip_address \
		    $alias_subnet_arg
		route add $alias_ip_address 127.0.0.1
	fi
	make_resolv_conf
	exit_with_hooks 0
	;;

EXPIRE|FAIL|RELEASE|STOP)
	if [ ! -z "$old_nis_domain" ]; then
		if type domainname > /dev/null 2>&1; then
			# delete the old nis domain name
			domainname ""
		fi
	fi

	if [ ! -z "$alias_ip_address" ]; then
		ifconfig $interface inet -alias $alias_ip_address 
		route delete $alias_ip_address 127.0.0.1
	fi > /dev/null 2>&1

	if [ ! -z "$old_ip_address" ]; then
		eval "ifconfig $interface inet -alias $old_ip_address $medium"
		route delete $old_ip_address 127.0.0.1 >/dev/null 2>&1
		delete_old_routes

	fi

	if [ ! -z "$alias_ip_address" ]; then
		ifconfig $interface inet alias $alias_ip_address \
		    $alias_subnet_arg
		route add $alias_ip_address 127.0.0.1
	fi

	restore_resolv_conf
	exit_with_hooks 0
	;;

TIMEOUT)
	if [ ! -z "$alias_ip_address" ]; then
		ifconfig $interface inet -alias $alias_ip_address
		route delete $alias_ip_address 127.0.0.1
	fi > /dev/null 2>&1

	if [ ! -z "$new_host_name" ]; then
		if type hostname > /dev/null 2>&1; then
			hostname $new_host_name
		fi
	fi

	if [ ! -z "$new_nis_domain" ]; then
		if type domainname > /dev/null 2>&1; then
			domainname $new_nis_domain
		fi
	fi

	eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
	    $new_broadcast_arg $medium"
	sleep 1

	if [ ! -z "$new_routers" ]; then
		set -- $new_routers
		if ping -n -q -c 1 -w 1 $1; then
			if [ \( ! -z "$alias_ip_address" \) -a \
			    \( "x$new_ip_address" != "x$alias_ip_address" \) ]
			then
				ifconfig $interface inet alias \
				    $alias_ip_address $alias_subnet_arg
				route add $alias_ip_address 127.0.0.1
			fi

			route add $new_ip_address 127.0.0.1 >/dev/null 2>&1

			add_new_routes
			make_resolv_conf
			exit_with_hooks 0
		fi
	fi

	eval "ifconfig $interface inet -alias $new_ip_address $medium"

	delete_old_routes

	exit_with_hooks 1
	;;
*)
	exit_with_hooks 0
	;;
esac
@


1.13
log
@Use resolvconf(8) to manage /etc/resolv.conf
@
text
@d3 1
a3 1
# $NetBSD: dhclient-script,v 1.12 2006/10/08 17:09:32 riz Exp $
@


1.13.6.1
log
@sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs.  ("Protocol error: too many arguments")
@
text
@d3 1
a3 1
# $NetBSD: dhclient-script,v 1.13 2009/11/21 07:53:59 roy Exp $
@


1.13.12.1
log
@resync from head
@
text
@d3 1
a3 1
# $NetBSD: dhclient-script,v 1.13 2009/11/21 07:53:59 roy Exp $
@


1.12
log
@Note which interface caused a resolv.conf to be created.  From
Robert Elz in PR#21109, tested by Rivo Nurges.
@
text
@d3 1
a3 1
# $NetBSD: dhclient-script,v 1.11 2006/09/23 22:54:43 dyoung Exp $
d11 8
d21 15
a35 16
		if [ -f $RESOLV ]
		then
			while read line; do
				case $line in
				"$SIGNATURE"*)
					;;
				*)
					mv $RESOLV $RESOLV.save;;
				esac
				break
			done < $RESOLV
		fi
		echo "$INTSIG" > $RESOLV
		if [ ! -z "$new_domain_name" ]
		then
			echo search $new_domain_name >> $RESOLV
a36 3
		for nameserver in $new_domain_name_servers; do
			echo nameserver $nameserver
		done >> $RESOLV
d41 3
a43 2
	if [ -f $RESOLV.save -a -f $RESOLV ]
	then
@


1.11
log
@Replace the arp -n -a / arp -n -d rigamarole for cleaning the ARP
table with 'route -n flush -inet -llinfo -host', which is not only
more concise, but it doesn't require /usr/ to be mounted.  This
lets us close bin/11079.
@
text
@d3 1
a3 1
# $NetBSD: dhclient-script,v 1.10 2006/07/10 23:07:09 christos Exp $
d8 2
a9 1
SIGNATURE="# Created by dhclient"
d25 1
a25 1
		echo "$SIGNATURE" > $RESOLV
d41 1
a41 1
			"$SIGNATURE"*)
@


1.10
log
@We don't need sed to do trivial parsing.
@
text
@d3 1
a3 1
# $NetBSD: dhclient-script,v 1.9 2005/07/16 08:41:27 rtr Exp $
d82 1
a82 6
	local name addr rest
	arp -n -a | while read name addr rest
	do
		addr=${addr#(}
		arp -n -d ${addr%)}
	done
@


1.9
log
@avoid ifconfig <if> "" it serves no purpose
patch from Robert Elz via pr#21110
@
text
@d3 1
a3 1
# $NetBSD: dhclient-script,v 1.8 2005/06/19 05:04:34 blymn Exp $
d82 6
a87 1
	arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' | sh
@


1.8
log
@Fix up the adding of static routes, incorrect parameters were being passed
to the route command.
@
text
@d3 1
a3 1
# $NetBSD: dhclient-script,v 1.7 2005/04/09 02:14:52 atatat Exp $
d131 1
@


1.7
log
@Remove the date from the generated resolv.conf file, since changes to
this file are tracked by /etc/security, making it (the backup) get
needlessly updated when you go to and from work every day.
@
text
@d3 1
a3 1
# $NetBSD: dhclient-script,v 1.6 2004/10/04 12:54:06 grant Exp $
d66 1
a66 1
		route add $0 $1
@


1.6
log
@suppress printing the network settings so that dhclient -q is actually
quiet. the most useful network info is already printed by dhclient
itself in noisy mode.
@
text
@d3 1
a3 1
# $NetBSD: dhclient-script,v 1.5 2002/05/28 15:04:01 christos Exp $
d8 1
a8 1
SIGNATURE="# Created by dhclient at: "
d24 1
a24 1
		echo "$SIGNATURE$(date)" > $RESOLV
@


1.6.2.1
log
@Pull up following revision(s) (requested by tron in ticket #1545):
	usr.sbin/dhcp/clientscript/dhclient-script: revision 1.7
Remove the date from the generated resolv.conf file, since changes to
this file are tracked by /etc/security, making it (the backup) get
needlessly updated when you go to and from work every day.
@
text
@d3 1
a3 1
# $NetBSD$
d8 1
a8 1
SIGNATURE="# Created by dhclient"
d24 1
a24 1
		echo "$SIGNATURE" > $RESOLV
@


1.5
log
@update resolv.conf if we have new nameservers. Don't require a domain, because
it is not needed.
@
text
@d3 1
a3 1
# $NetBSD: dhclient-script,v 1.4 2002/04/10 10:11:41 enami Exp $
d96 11
a106 11
if [ ! -z "$new_host_name" ]; then
	echo New Host Name: $new_host_name
fi

if [ ! -z "$new_nis_domain" ]; then
	echo New NIS Domain: $new_nis_domain
fi

if [ ! -z "$new_network_number" ]; then
	echo New Network Number: $new_network_number
fi
d109 1
a109 1
	echo New Broadcast Address: $new_broadcast_address
@


1.4
log
@- Don't assume that /usr is available.  Fixes (one of?) ``fgrep: not found''.
- Don't append ``dot'' when restoring resovl.conf.
@
text
@d3 1
a3 1
# $NetBSD: dhclient-script,v 1.3 2002/04/02 19:16:59 christos Exp $
d11 1
a11 2
	if [ \( ! -z "$new_domain_name" \) -a \
	     \( ! -z "$new_domain_name_servers" \) ]; then
@


1.4.2.1
log
@Pullup rev 1.5 (requested by aymeric in ticket #1546)

Update resolv.conf if we have new nameservers. Don't require a domain, because
it is not needed.
@
text
@d3 1
a3 1
# $NetBSD: dhclient-script,v 1.4 2002/04/10 10:11:41 enami Exp $
d11 2
a12 1
	if [ ! -z "$new_domain_name_servers" ]; then
@


1.3
log
@don't add a search line if the domain name is empty. Pointed out by perry.
@
text
@d3 1
a3 1
# $NetBSD: dhclient-script,v 1.2 2002/04/02 17:39:47 christos Exp $
d15 9
a23 4
			if ! fgrep -q "$SIGNATURE" $RESOLV
			then
				mv $RESOLV $RESOLV.save
			fi
d39 7
a45 4
		if fgrep -q "$SIGNATURE" $RESOLV
		then
			mv $RESOLV.save $RESOLV.
		fi
@


1.2
log
@- don't trash the old resolv.conf.
- say that we generated it and when.
- unfortunately we cannot restore it back, since dhclient does not call us
  when it exits.
@
text
@d3 1
a3 1
# $NetBSD: dhclient-script,v 1.1 2001/08/03 14:30:19 drochner Exp $
d21 4
a24 1
		echo search $new_domain_name >> $RESOLV
@


1.1
log
@our dhclient-script diverged too much from the distributed one,
keep it separate
@
text
@d3 1
a3 1
# $NetBSD: netbsd,v 1.17 2001/06/18 19:43:55 christos Exp $
d8 1
d13 9
a21 1
		echo search $new_domain_name > $RESOLV
d28 10
d225 1
@


1.1.2.1
log
@file dhclient-script was added on branch netbsd-1-5 on 2001-08-16 18:53:28 +0000
@
text
@d1 259
@


1.1.2.2
log
@Pullup [drochner]:

distrib/notes/common/main                       patch
distrib/sets/lists/base/mi                      1.270 by patch
distrib/sets/lists/man/mi                       1.390 by patch
usr.sbin/dhcp/Makefile                          sync with 1.12
usr.sbin/dhcp/Makefile.inc                      sync with 1.15
usr.sbin/dhcp/client/Makefile                   1.13-1.14
usr.sbin/dhcp/clientscript/Makefile             1.1-1.2
usr.sbin/dhcp/clientscript/dhclient-script      1.1
usr.sbin/dhcp/common/Makefile                   1.19
usr.sbin/dhcp/dhcpctl/Makefile                  1.2
usr.sbin/dhcp/dst/Makefile                      1.3-1.4
usr.sbin/dhcp/minires/Makefile                  1.4-1.5
usr.sbin/dhcp/omapip/Makefile                   1.4-1.5
usr.sbin/dhcp/omshell/Makefile                  1.1-1.2
usr.sbin/dhcp/relay/Makefile                    1.3
usr.sbin/dhcp/server/Makefile                   1.11-1.12
usr.sbin/dhcp/(others)                          remove

  Update dhcp to Version 3, Release Candidate 10.
@
text
@a0 259
#!/bin/sh
#
# $NetBSD: dhclient-script,v 1.1.2.1 2001/08/16 18:53:28 tv Exp $

ENTERHOOKS=/etc/dhclient-enter-hooks
EXITHOOKS=/etc/dhclient-exit-hooks
RESOLV=/etc/resolv.conf

make_resolv_conf() {
	if [ \( ! -z "$new_domain_name" \) -a \
	     \( ! -z "$new_domain_name_servers" \) ]; then
		echo search $new_domain_name > $RESOLV
		for nameserver in $new_domain_name_servers; do
			echo nameserver $nameserver
		done >> $RESOLV
	fi
}

# Must be used on exit.   Invokes the local dhcp client exit hooks, if any.
exit_with_hooks() {
	exit_status=$1
	if [ -f "$EXITHOOKS" ]; then
		. "$EXITHOOKS"
	fi
	# probably should do something with exit status of the local script
	exit $exit_status
}


add_new_routes() {
	for router in $new_routers; do
		route add default $router
	done >/dev/null 2>&1

	set -- $new_static_routes
	while [ $# -gt 1 ]; do
		route add $0 $1
		shift; shift
	done
}

delete_old_routes() {
	for router in $old_routers; do
		route delete default $router
	done >/dev/null 2>&1

	set -- $old_static_routes
	while [ $# -gt 1 ]; do
		route delete $1 $2
		shift; shift
	done

	arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' | sh
}

# Invoke the local dhcp client enter hooks, if they exist.
if [ -f $ENTERHOOKS ]; then
	exit_status=0
	. $ENTERHOOKS
	# allow the local script to abort processing of this state
	# local script must set exit_status variable to nonzero.
	if [ $exit_status -ne 0 ]; then
		exit $exit_status
	fi
fi

if [ ! -z "$new_host_name" ]; then
	echo New Host Name: $new_host_name
fi

if [ ! -z "$new_nis_domain" ]; then
	echo New NIS Domain: $new_nis_domain
fi

if [ ! -z "$new_network_number" ]; then
	echo New Network Number: $new_network_number
fi

if [ ! -z "$new_broadcast_address" ]; then
	echo New Broadcast Address: $new_broadcast_address
	new_broadcast_arg="broadcast $new_broadcast_address"
fi

if [ ! -z "$old_broadcast_address" ]; then
	old_broadcast_arg="broadcast $old_broadcast_address"
fi

if [ ! -z "$new_subnet_mask" ]; then
	new_netmask_arg="netmask $new_subnet_mask"
fi

if [ ! -z "$old_subnet_mask" ]; then
	old_netmask_arg="netmask $old_subnet_mask"
fi

if [ ! -z "$alias_subnet_mask" ]; then
	alias_subnet_arg="netmask $alias_subnet_mask"
fi

case "$reason" in
MEDIUM)
	eval "ifconfig $interface $medium"
	eval "ifconfig $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1

	sleep 1

	exit_with_hooks 0
	;;

PREINIT)
	if [ ! -z "$alias_ip_address" ]; then
		ifconfig $interface inet \
		    -alias $alias_ip_address >/dev/null 2>&1
		route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
	fi

	ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
	    broadcast 255.255.255.255 up

	exit_with_hooks 0
	;;

ARPCHECK|ARPSEND)
	exit_with_hooks 0
	;;

BOUND|RENEW|REBIND|REBOOT)
	if [ ! -z "$new_nis_domain" ]; then
		if type domainname > /dev/null 2>&1; then
			domainname $new_nis_domain
		fi
	fi

	if type hostname > /dev/null 2>&1; then
		if [ \( -z "$current_hostname" \) -o \
		    \( "x$new_host_name" = "x$old_hostname" \) ]; then
			current_hostname=`hostname`
		fi
		if [ \( -z "$current_hostname" \) -o \
		    \( "x$new_host_name" != "x$old_hostname" \) ]; then
			hostname $new_host_name
		fi
	fi
    
	if [ \( ! -z "$old_ip_address" \) -a \( ! -z "$alias_ip_address" \) -a \
	    \( "x$alias_ip_address" != "x$old_ip_address" \) ]; then
		ifconfig $interface inet \
		    -alias $alias_ip_address > /dev/null 2>&1
		route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
	fi

	if [ \( ! -z "$old_ip_address" \) -a \
	    \( "x$old_ip_address" != "x$new_ip_address" \) ]; then
		eval "ifconfig $interface inet -alias $old_ip_address $medium"
		route delete $old_ip_address 127.0.0.1 >/dev/null 2>&1

		delete_old_routes
	fi

	if [ \( -z "$old_ip_address" \) -o \
	    \( "x$old_ip_address" != "x$new_ip_address" \) -o \
	    \( "x$reason" = "xBOUND" \) -o \( "x$reason" = "xREBOOT" \) ]; then
		eval "ifconfig $interface inet $new_ip_address \
		    $new_netmask_arg $new_broadcast_arg $medium"
		route add $new_ip_address 127.0.0.1 >/dev/null 2>&1

		add_new_routes
	fi

	if [ \( ! -z "$alias_ip_address" \) -a \
	    \( "x$new_ip_address" != "x$alias_ip_address" \) ]; then
		ifconfig $interface inet alias $alias_ip_address \
		    $alias_subnet_arg
		route add $alias_ip_address 127.0.0.1
	fi
	make_resolv_conf
	exit_with_hooks 0
	;;

EXPIRE|FAIL|RELEASE|STOP)
	if [ ! -z "$old_nis_domain" ]; then
		if type domainname > /dev/null 2>&1; then
			# delete the old nis domain name
			domainname ""
		fi
	fi

	if [ ! -z "$alias_ip_address" ]; then
		ifconfig $interface inet -alias $alias_ip_address 
		route delete $alias_ip_address 127.0.0.1
	fi > /dev/null 2>&1

	if [ ! -z "$old_ip_address" ]; then
		eval "ifconfig $interface inet -alias $old_ip_address $medium"
		route delete $old_ip_address 127.0.0.1 >/dev/null 2>&1
		delete_old_routes

	fi

	if [ ! -z "$alias_ip_address" ]; then
		ifconfig $interface inet alias $alias_ip_address \
		    $alias_subnet_arg
		route add $alias_ip_address 127.0.0.1
	fi

	exit_with_hooks 0
	;;

TIMEOUT)
	if [ ! -z "$alias_ip_address" ]; then
		ifconfig $interface inet -alias $alias_ip_address
		route delete $alias_ip_address 127.0.0.1
	fi > /dev/null 2>&1

	if [ ! -z "$new_host_name" ]; then
		if type hostname > /dev/null 2>&1; then
			hostname $new_host_name
		fi
	fi

	if [ ! -z "$new_nis_domain" ]; then
		if type domainname > /dev/null 2>&1; then
			domainname $new_nis_domain
		fi
	fi

	eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
	    $new_broadcast_arg $medium"
	sleep 1

	if [ ! -z "$new_routers" ]; then
		set -- $new_routers
		if ping -n -q -c 1 -w 1 $1; then
			if [ \( ! -z "$alias_ip_address" \) -a \
			    \( "x$new_ip_address" != "x$alias_ip_address" \) ]
			then
				ifconfig $interface inet alias \
				    $alias_ip_address $alias_subnet_arg
				route add $alias_ip_address 127.0.0.1
			fi

			route add $new_ip_address 127.0.0.1 >/dev/null 2>&1

			add_new_routes
			make_resolv_conf
			exit_with_hooks 0
		fi
	fi

	eval "ifconfig $interface inet -alias $new_ip_address $medium"

	delete_old_routes

	exit_with_hooks 1
	;;
*)
	exit_with_hooks 0
	;;
esac
@
