mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-12-30 15:38:06 +01:00
688e303c19
only work if there's just one interface doing dhcp. This version implements the same logic as the version in the PR, but uses pgrep to be less verbose. PR: conf/95905 MFC after: 1 week
65 lines
1.1 KiB
Bash
Executable File
65 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
|
|
# PROVIDE: dhclient
|
|
# KEYWORD: nojail nostart
|
|
|
|
. /etc/rc.subr
|
|
. /etc/network.subr
|
|
|
|
name="dhclient"
|
|
rcvar=
|
|
start_cmd="dhclient_start"
|
|
stop_cmd="dhclient_stop"
|
|
|
|
dhclient_start()
|
|
{
|
|
# prevent unnecessary restarts
|
|
# XXX: dhclient had better create a pidfile
|
|
if [ -x /bin/pgrep ]; then
|
|
pids=`/bin/pgrep -f "dhclient: $ifn(\$| .*)"`
|
|
if [ -n "$pids" ]; then
|
|
sleep 1
|
|
pids=`/bin/pgrep -f "dhclient: $ifn(\$| .*)"`
|
|
if [ -n "$pids" ]; then
|
|
exit 0
|
|
fi
|
|
elif [ -e /var/run/dhclient.pid ]; then
|
|
if [ -n "`pgrep -F /var/run/dhclient.pid`" ]; then
|
|
exit 0
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
# Override for $ifn specific flags (see rc.subr for $flags setting)
|
|
specific=`get_if_var $ifn dhclient_flags_IF`
|
|
if [ -z "$flags" -a -n "$specific" ]; then
|
|
rc_flags=$specific
|
|
fi
|
|
|
|
background_dhclient=`get_if_var $ifn background_dhclient_IF $background_dhclient`
|
|
if checkyesno background_dhclient; then
|
|
rc_flags="${rc_flags} -b"
|
|
fi
|
|
|
|
${dhclient_program} ${rc_flags} $ifn
|
|
}
|
|
|
|
dhclient_stop()
|
|
{
|
|
ifconfig $ifn down # cause dhclient to die
|
|
}
|
|
|
|
ifn="$2"
|
|
|
|
load_rc_config $name
|
|
load_rc_config network
|
|
|
|
if ! dhcpif $ifn; then
|
|
return 1
|
|
fi
|
|
|
|
run_rc_command "$1"
|