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-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
|
2005-06-07 04:49:12 +00:00
|
|
|
# XXX: should use a pidfile
|
|
|
|
if [ -x /usr/bin/pgrep ]; then
|
|
|
|
pids=`/usr/bin/pgrep -f "dhclient: $ifn(\$| .*)"`
|
|
|
|
if [ -n "$pids" ]; then
|
|
|
|
exit 0
|
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)
|
|
|
|
eval specific=\$dhclient_flags_$ifn
|
|
|
|
if [ -z "$flags" -a -n "$specific" ]; then
|
|
|
|
rc_flags=$specific
|
|
|
|
fi
|
|
|
|
|
|
|
|
eval specific=\$background_dhclient_$ifn
|
2006-08-17 19:57:10 +00:00
|
|
|
if [ -n "$specific" ]; then
|
2006-08-17 17:12:27 +00:00
|
|
|
if checkyesno background_dhclient_$ifn; then
|
|
|
|
rc_flags="${rc_flags} -b"
|
|
|
|
fi
|
|
|
|
elif 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"
|