dhclient revision 160197
1#!/bin/sh
2#
3# $NetBSD: dhclient,v 1.8 2002/03/22 04:33:58 thorpej Exp $
4# $FreeBSD: head/etc/rc.d/dhclient 160197 2006-07-09 06:54:24Z stefanf $
5#
6
7# PROVIDE: dhclient
8# KEYWORD: nojail nostart
9#
10
11. /etc/rc.subr
12. /etc/network.subr
13
14name="dhclient"
15rcvar=
16start_cmd="dhclient_start"
17stop_cmd="dhclient_stop"
18
19dhclient_start()
20{
21	# prevent unnecessary restarts
22	# XXX: should use a pidfile
23	if [ -x /usr/bin/pgrep ]; then
24		pids=`/usr/bin/pgrep -f "dhclient: $ifn(\$| .*)"`
25		if [ -n "$pids" ]; then
26			exit 0
27		fi
28	fi
29
30	if checkyesno background_dhclient; then
31		rc_flags="${rc_flags} -b"
32	fi
33
34	${dhclient_program} ${rc_flags} $ifn
35}
36
37dhclient_stop()
38{
39	ifconfig $ifn down	# cause dhclient to die
40}
41
42ifn="$2"
43
44load_rc_config $name
45
46if ! dhcpif $ifn; then
47	return 1
48fi
49
50run_rc_command "$1"
51