blob: bada5e88a48606e38a562520f7619708d088a555 [file] [log] [blame]
#!/bin/sh
iface=$1
lock=/var/run/dhclient.$iface.lock
lockfile-create --use-pid $lock
run_dhclient() {
local suffix="$1" xargs="$2"
local pidfile="/var/run/dhclient$suffix.$iface.pid"
local leasefile="/var/run/dhclient$suffix.$iface.lease"
local conffile="/etc/dhclient$suffix.conf"
# kill any existing babysitters and dhclients
# [-] is a trick to not match the pkill itself
pkill -f "(babysit|dhclient).*[-]pf $pidfile "
babysit 60 dhclient "$iface" $xargs \
-d \
-pf "$pidfile" \
-lf "$leasefile" \
-cf "$conffile" \
2>&1 | logos "dhclient$suffix.$iface" &
}
run_dhclient "" ""
# -N -P means to request a delegated prefix AND get a address.
# -S means runs stateless config, requests only the extra information.
# On the network box we only run the stateful version, running both
# interfere with each other.
if is-network-box; then
# stateful + prefix delegation
run_dhclient "6" "-N -P -6 --never-gonna-give-you-up 900"
elif is-ptp || is-fiberjack; then
# TODO(edjames): unfork /etc/config/ifup.default and use this for FJ
# stateful
run_dhclient "6" "-6 --never-gonna-give-you-up 900"
else
# stateless + slaac
run_dhclient "6" "-S -6 --never-gonna-give-you-up 900"
fi
lockfile-remove $lock