166830Sobrien#!/bin/sh
266830Sobrien#
366830Sobrien# Copyright (c) 1999  Matt Dillon
466830Sobrien# All rights reserved.
566830Sobrien#
666830Sobrien# Redistribution and use in source and binary forms, with or without
766830Sobrien# modification, are permitted provided that the following conditions
866830Sobrien# are met:
966830Sobrien# 1. Redistributions of source code must retain the above copyright
1066830Sobrien#    notice, this list of conditions and the following disclaimer.
1166830Sobrien# 2. Redistributions in binary form must reproduce the above copyright
1266830Sobrien#    notice, this list of conditions and the following disclaimer in the
1366830Sobrien#    documentation and/or other materials provided with the distribution.
1466830Sobrien#
1566830Sobrien# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1666830Sobrien# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1766830Sobrien# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1866830Sobrien# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1966830Sobrien# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2066830Sobrien# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2166830Sobrien# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2266830Sobrien# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2366830Sobrien# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2466830Sobrien# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25100280Sgordon# SUCH DAMAGE.
2651231Ssheldonh#
2766830Sobrien# $FreeBSD$
2866830Sobrien#
2943803Sdillon
30127345Sbrooks# PROVIDE: resolv
31242153Sobrien# REQUIRE: netif FILESYSTEMS
32136224Smtm# KEYWORD: nojail
3375931Simp
34127345Sbrooks. /etc/rc.subr
3576409Sbsd
36127345Sbrooksname="resolv"
37174464Sdougbstop_cmd=':'
3876409Sbsd
39127345Sbrooksload_rc_config $name
4043803Sdillon
41108191Sdillon# if the info is available via dhcp/kenv
42108191Sdillon# build the resolv.conf
43108191Sdillon#
44225670Shrsif [ -n "`/bin/kenv dhcp.domain-name-servers 2> /dev/null`" ]; then
45225670Shrs	interface="`/bin/kenv boot.netif.name`"
46225670Shrs	(
47127345Sbrooks	if [ -n "`/bin/kenv dhcp.domain-name 2> /dev/null`" ]; then
48225670Shrs		echo domain `/bin/kenv dhcp.domain-name`
49127345Sbrooks	fi
50127345Sbrooks
51170198Sdougb	set -- `/bin/kenv dhcp.domain-name-servers`
52170198Sdougb	for ns in `IFS=','; echo $*`; do
53225670Shrs		echo nameserver $ns
54170198Sdougb	done
55225670Shrs	) | /sbin/resolvconf -a ${interface}:dhcp4
56108191Sdillonfi
57108191Sdillon
58