31 lines
788 B
Bash
31 lines
788 B
Bash
start_dhclient() {
|
|
local interface=$1
|
|
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
|
dhclient -x
|
|
dhclient -nw "$interface"
|
|
elif [[ "$OSTYPE" == "freebsd"* ]]; then
|
|
# prefer isc-dhcp-client as it supports dhcpv6
|
|
if [[ -x /usr/local/sbin/dhclient ]]; then
|
|
/usr/local/sbin/dhclient -x
|
|
/usr/local/sbin/dhclient -nw "$interface"
|
|
else
|
|
dhclient -b "$interface"
|
|
fi
|
|
else
|
|
nohup setsid dhclient "$interface" >/dev/null 2>&1
|
|
fi
|
|
}
|
|
|
|
start_dhcp() {
|
|
local interface=$1
|
|
if has dhcpcd; then
|
|
dhcpcd -b -n "$interface"
|
|
elif has dhclient; then
|
|
start_dhclient "$interface"
|
|
elif [[ "$OSTYPE" == "darwin"* ]]; then # TODO untested
|
|
ipconfig set "$interface" DHCP
|
|
else
|
|
die "no suitable dhcp program found, need dhcpcd or dhclient"
|
|
fi
|
|
}
|