summaryrefslogtreecommitdiffstats
path: root/etc/rc.d/dhclient
blob: 93848f22f0cee52c21522499cfdef06f346c5577 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh
#
# $NetBSD: dhclient,v 1.8 2002/03/22 04:33:58 thorpej Exp $
# $FreeBSD$
#

# PROVIDE: dhclient
# KEYWORD: nojail nostart
#

. /etc/rc.subr
. /etc/network.subr

name="dhclient"
rcvar=
start_cmd="dhclient_start"
stop_cmd="dhclient_stop"

dhclient_start()
{
	# prevent unnecessary restarts
	# XXX: dhclient had better create a pidfile
	if [ -x /bin/pgrep ]; then
		pids=`/bin/pgrep -f "dhclient: $ifn(\$| .*)"`
		if [ -n "$pids" ]; then
			exit 0
		fi
	fi

	# Override for $ifn specific flags (see rc.subr for $flags setting)
	specific=`get_if_var $ifn dhclient_flags_IF`
	if [ -z "$flags" -a -n "$specific" ]; then
		rc_flags=$specific
	fi

	background_dhclient=`get_if_var $ifn background_dhclient_IF $background_dhclient`
	if checkyesno background_dhclient; then
		rc_flags="${rc_flags} -b"
	fi

	${dhclient_program} ${rc_flags} $ifn
}

dhclient_stop()
{
	ifconfig $ifn down	# cause dhclient to die
}

ifn="$2"

load_rc_config $name
load_rc_config network

if ! dhcpif $ifn; then
	return 1
fi

run_rc_command "$1"
OpenPOWER on IntegriCloud