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
|
2005-06-07 04:49:12 +00:00
|
|
|
# KEYWORD: nojail 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
|
|
|
|
|
|
|
name="dhclient"
|
2004-01-17 10:40:45 +00:00
|
|
|
rcvar=
|
2005-06-07 04:49:12 +00:00
|
|
|
start_cmd="dhclient_start"
|
|
|
|
stop_cmd="dhclient_stop"
|
2003-04-18 17:53:02 +00:00
|
|
|
|
2005-06-07 04:49:12 +00:00
|
|
|
dhclient_start()
|
2003-04-18 17:53:02 +00:00
|
|
|
{
|
2006-07-09 06:54:24 +00:00
|
|
|
# prevent unnecessary restarts
|
2007-02-15 06:51:31 +00:00
|
|
|
# XXX: dhclient had better create a pidfile
|
|
|
|
if [ -x /bin/pgrep ]; then
|
|
|
|
pids=`/bin/pgrep -f "dhclient: $ifn(\$| .*)"`
|
2005-06-07 04:49:12 +00:00
|
|
|
if [ -n "$pids" ]; then
|
2008-02-01 23:43:58 +00:00
|
|
|
sleep 1
|
|
|
|
pids=`/bin/pgrep -f "dhclient: $ifn(\$| .*)"`
|
|
|
|
if [ -n "$pids" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
2008-04-15 23:03:35 +00:00
|
|
|
elif [ -e /var/run/dhclient.pid ]; then
|
|
|
|
if [ -n "`pgrep -F /var/run/dhclient.pid`" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
2003-06-29 05:34:41 +00:00
|
|
|
fi
|
|
|
|
fi
|
2003-04-20 19:14:16 +00:00
|
|
|
|
2006-08-17 17:12:27 +00:00
|
|
|
# Override for $ifn specific flags (see rc.subr for $flags setting)
|
2007-03-02 20:48:35 +00:00
|
|
|
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
|
|
|
|
|
2007-03-02 20:48:35 +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
|
|
|
|
|
2005-06-07 04:49:12 +00:00
|
|
|
${dhclient_program} ${rc_flags} $ifn
|
2003-04-18 17:53:02 +00:00
|
|
|
}
|
|
|
|
|
2005-06-07 04:49:12 +00:00
|
|
|
dhclient_stop()
|
2003-04-18 17:53:02 +00:00
|
|
|
{
|
2005-06-07 04:49:12 +00:00
|
|
|
ifconfig $ifn down # cause dhclient to die
|
2003-04-18 17:53:02 +00:00
|
|
|
}
|
2001-06-16 07:16:14 +00:00
|
|
|
|
2005-06-07 04:49:12 +00:00
|
|
|
ifn="$2"
|
2003-06-29 05:34:41 +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
|
|
|
|
2005-06-07 04:49:12 +00:00
|
|
|
if ! dhcpif $ifn; then
|
|
|
|
return 1
|
2003-06-29 05:34:41 +00:00
|
|
|
fi
|
|
|
|
|
2001-06-16 07:16:14 +00:00
|
|
|
run_rc_command "$1"
|