blob: 895d34aece09fc51fc31a61398197b353114ecd3 (
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
#!/bin/sh
#
# $NetBSD: dhclient,v 1.8 2002/03/22 04:33:58 thorpej Exp $
# $FreeBSD$
#
# PROVIDE: dhclient
# REQUIRE: network netif mountcritlocal
# BEFORE: NETWORKING
# KEYWORD: FreeBSD NetBSD
#
# Note that there no syslog logging of dhclient messages at boot because
# dhclient needs to start before services that syslog depends upon do.
#
. /etc/rc.subr
. /etc/network.subr
name="dhclient"
pidfile="/var/run/${name}.pid"
case "${OSTYPE}" in
FreeBSD)
rcvar=
start_precmd="dhclient_prestart"
start_postcmd="dhclient_poststart"
stop_precmd="dhclient_prestop"
stop_postcmd="dhclient_poststop"
;;
NetBSD)
rcvar=$name
command="/sbin/${name}"
;;
esac
dhclient_common()
{
dhcp_list="`list_net_interfaces dhcp`"
if [ -z "$dhcp_list" ]; then
return 1
fi
# Determine the scope of the command
#
_cooked_list="$dhcp_list"
if [ -n "$_cmdifn" ]; then
eval _cooked_list=\"`expr "$dhcp_list" : ".*\($_cmdifn\).*"`\"
if [ -z "$_cooked_list" ]; then
err "No such network interface: $_cmdifn"
return 1
fi
fi
}
dhclient_prestart()
{
dhclient_common || return 1
for ifn in ${_cooked_list}; do
ifscript_up ${ifn}
done
if checkyesno background_dhclient; then
rc_flags="${rc_flags} -nw"
fi
rc_flags="${rc_flags} ${_cooked_list}"
return 0
}
dhclient_poststart()
{
for ifn in ${_cooked_list}; do
ifalias_up ${ifn}
ipx_up ${ifn}
ifconfig ${ifn}
done
}
dhclient_prestop()
{
dhclient_common || return 1
for ifn in ${_cooked_list}; do
ipx_down ${ifn}
ifalias_down ${ifn}
done
echo -n "Releasing DHCP leases:"
for ifn in $_cooked_list ; do
${command} -r $ifn
if [ $? -eq 0 ]; then
echo -n " $ifn"
else
_fail="$_fail $ifn"
fi
done
echo '.'
debug "The following leases failed to release: $_fail"
}
dhclient_poststop()
{
for ifn in ${_cooked_list}; do
ifscript_down ${ifn}
done
}
if [ -n "$2" ]; then
_cmdifn="$2"
stop_cmd=":"
fi
load_rc_config $name
run_rc_command "$1"
|