2001-06-16 07:16:14 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2002-06-13 22:14:37 +00:00
|
|
|
# $NetBSD: dhclient,v 1.8 2002/03/22 04:33:58 thorpej Exp $
|
|
|
|
# $FreeBSD$
|
2001-06-16 07:16:14 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: dhclient
|
2005-01-16 03:12:03 +00:00
|
|
|
# REQUIRE: netif ipfw ipfilter mountcritlocal cleanvar
|
2002-06-13 22:14:37 +00:00
|
|
|
# BEFORE: NETWORKING
|
2004-10-07 13:55:26 +00:00
|
|
|
# KEYWORD: nojail
|
2001-06-16 07:16:14 +00:00
|
|
|
#
|
|
|
|
# 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
|
2003-04-18 17:53:02 +00:00
|
|
|
. /etc/network.subr
|
2001-06-16 07:16:14 +00:00
|
|
|
|
|
|
|
name="dhclient"
|
2004-01-17 10:40:45 +00:00
|
|
|
rcvar=
|
2001-06-16 07:16:14 +00:00
|
|
|
pidfile="/var/run/${name}.pid"
|
2004-01-17 10:40:45 +00:00
|
|
|
start_precmd="dhclient_prestart"
|
|
|
|
start_postcmd="dhclient_poststart"
|
|
|
|
stop_precmd="dhclient_prestop"
|
|
|
|
stop_postcmd="dhclient_poststop"
|
2003-04-18 17:53:02 +00:00
|
|
|
|
2003-06-29 05:34:41 +00:00
|
|
|
dhclient_common()
|
2003-04-18 17:53:02 +00:00
|
|
|
{
|
|
|
|
dhcp_list="`list_net_interfaces dhcp`"
|
|
|
|
if [ -z "$dhcp_list" ]; then
|
|
|
|
return 1
|
|
|
|
fi
|
2003-04-20 19:14:16 +00:00
|
|
|
|
2003-06-29 05:34:41 +00:00
|
|
|
# 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
|
2004-05-20 14:16:05 +00:00
|
|
|
err 1 "No such network interface: $_cmdifn"
|
2003-06-29 05:34:41 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
dhclient_prestart()
|
|
|
|
{
|
2003-09-16 02:56:13 +00:00
|
|
|
if [ $dhclient_common_error -eq 1 ]; then
|
|
|
|
return 1
|
|
|
|
fi
|
2003-06-29 05:34:41 +00:00
|
|
|
for ifn in ${_cooked_list}; do
|
2003-04-20 19:14:16 +00:00
|
|
|
ifscript_up ${ifn}
|
|
|
|
done
|
|
|
|
|
2003-07-28 08:15:52 +00:00
|
|
|
if checkyesno background_dhclient; then
|
|
|
|
rc_flags="${rc_flags} -nw"
|
|
|
|
fi
|
|
|
|
|
2003-06-29 05:34:41 +00:00
|
|
|
rc_flags="${rc_flags} ${_cooked_list}"
|
2003-04-18 17:53:02 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
dhclient_poststart()
|
|
|
|
{
|
2003-06-29 05:34:41 +00:00
|
|
|
for ifn in ${_cooked_list}; do
|
2003-04-18 17:53:02 +00:00
|
|
|
ifalias_up ${ifn}
|
|
|
|
ipx_up ${ifn}
|
|
|
|
ifconfig ${ifn}
|
|
|
|
done
|
|
|
|
}
|
2001-06-16 07:16:14 +00:00
|
|
|
|
2003-07-26 18:50:53 +00:00
|
|
|
dhclient_prestop()
|
2003-06-29 05:34:41 +00:00
|
|
|
{
|
2003-09-16 02:56:13 +00:00
|
|
|
if [ $dhclient_common_error -eq 1 ]; then
|
|
|
|
return 1
|
|
|
|
fi
|
2003-07-26 18:50:53 +00:00
|
|
|
for ifn in ${_cooked_list}; do
|
|
|
|
ipx_down ${ifn}
|
|
|
|
ifalias_down ${ifn}
|
|
|
|
done
|
2003-06-29 05:34:41 +00:00
|
|
|
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"
|
2003-07-26 18:58:46 +00:00
|
|
|
stop_cmd=":"
|
2003-06-29 05:34:41 +00:00
|
|
|
fi
|
|
|
|
|
2001-06-16 07:16:14 +00:00
|
|
|
load_rc_config $name
|
2003-09-16 02:56:13 +00:00
|
|
|
dhclient_common_error=0
|
|
|
|
dhclient_common || dhclient_common_error=1;
|
|
|
|
if [ -n "$_cooked_list" ]; then
|
|
|
|
if [ -s $pidfile ]; then
|
|
|
|
stop_cmd=":"
|
|
|
|
fi
|
|
|
|
fi
|
2001-06-16 07:16:14 +00:00
|
|
|
run_rc_command "$1"
|