2001-06-16 07:16:14 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2002-06-13 22:14:37 +00:00
|
|
|
# $FreeBSD$
|
2001-06-16 07:16:14 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: dhclient
|
2017-07-08 09:28:31 +00:00
|
|
|
# KEYWORD: nojailvnet nostart
|
2001-06-16 07:16:14 +00:00
|
|
|
|
|
|
|
. /etc/rc.subr
|
2003-04-18 17:53:02 +00:00
|
|
|
. /etc/network.subr
|
2001-06-16 07:16:14 +00:00
|
|
|
|
2011-10-13 17:20:45 +00:00
|
|
|
ifn="$2"
|
|
|
|
|
2001-06-16 07:16:14 +00:00
|
|
|
name="dhclient"
|
2016-04-23 16:10:54 +00:00
|
|
|
desc="Dynamic Host Configuration Protocol (DHCP) client"
|
2004-01-17 10:40:45 +00:00
|
|
|
rcvar=
|
2011-10-13 17:20:45 +00:00
|
|
|
pidfile="/var/run/${name}.${ifn}.pid"
|
|
|
|
start_precmd="dhclient_prestart"
|
2011-10-28 06:03:38 +00:00
|
|
|
stop_precmd="dhclient_pre_check"
|
|
|
|
|
|
|
|
# rc_force check can only be done at the run_rc_command
|
|
|
|
# time, so we're testing it in the pre* hooks.
|
|
|
|
dhclient_pre_check()
|
|
|
|
{
|
|
|
|
if [ -z "${rc_force}" ] && ! dhcpif $ifn; then
|
2012-01-12 06:48:11 +00:00
|
|
|
local msg
|
|
|
|
msg="'$ifn' is not a DHCP-enabled interface"
|
|
|
|
if [ -z "${rc_quiet}" ]; then
|
2012-01-20 17:19:50 +00:00
|
|
|
echo "$msg"
|
2012-01-12 06:48:11 +00:00
|
|
|
else
|
|
|
|
debug "$msg"
|
|
|
|
fi
|
2016-05-31 18:40:47 +00:00
|
|
|
exit 1
|
2011-10-28 06:03:38 +00:00
|
|
|
fi
|
|
|
|
}
|
2003-04-18 17:53:02 +00:00
|
|
|
|
2011-10-13 17:20:45 +00:00
|
|
|
dhclient_prestart()
|
2003-04-18 17:53:02 +00:00
|
|
|
{
|
2011-10-28 06:03:38 +00:00
|
|
|
dhclient_pre_check
|
|
|
|
|
2011-10-13 17:20:45 +00:00
|
|
|
# Interface-specific flags (see rc.subr for $flags setting)
|
|
|
|
specific=$(get_if_var $ifn dhclient_flags_IF)
|
2006-08-17 17:12:27 +00:00
|
|
|
if [ -z "$flags" -a -n "$specific" ]; then
|
|
|
|
rc_flags=$specific
|
|
|
|
fi
|
|
|
|
|
2011-10-13 17:20:45 +00:00
|
|
|
background_dhclient=$(get_if_var $ifn background_dhclient_IF $background_dhclient)
|
2007-03-25 19:45:20 +00:00
|
|
|
if checkyesno background_dhclient; then
|
2005-06-07 04:49:12 +00:00
|
|
|
rc_flags="${rc_flags} -b"
|
2003-07-28 08:15:52 +00:00
|
|
|
fi
|
|
|
|
|
2011-10-13 17:20:45 +00:00
|
|
|
rc_flags="${rc_flags} ${ifn}"
|
2003-04-18 17:53:02 +00:00
|
|
|
}
|
2001-06-16 07:16:14 +00:00
|
|
|
|
2005-06-07 04:49:12 +00:00
|
|
|
load_rc_config $name
|
2006-10-02 18:50:58 +00:00
|
|
|
load_rc_config network
|
2003-06-29 05:34:41 +00:00
|
|
|
|
2011-10-13 17:20:45 +00:00
|
|
|
if [ -z $ifn ] ; then
|
|
|
|
# only complain if a command was specified but no interface
|
|
|
|
if [ -n "$1" ] ; then
|
2011-10-28 06:03:38 +00:00
|
|
|
err 1 "$0: no interface specified"
|
2011-10-13 17:20:45 +00:00
|
|
|
fi
|
2003-06-29 05:34:41 +00:00
|
|
|
fi
|
|
|
|
|
2001-06-16 07:16:14 +00:00
|
|
|
run_rc_command "$1"
|