Make DHCP timeout configurable

As noted in the bug, there may be circumstances where a longer
timeout than the current default is needed.  This patch allows users
to tune this timeout for their environment if need be.

Change-Id: I173f3dad684894fbc3c27dece5ae15b5f63bae5a
Closes-Bug: 1654027
This commit is contained in:
Ben Nemec 2017-01-04 11:21:03 -06:00
parent 5bed4a6d5e
commit ccd00b10b2
3 changed files with 12 additions and 1 deletions

View File

@ -17,3 +17,13 @@ configured properly before networking services are started.
On Gentoo based distributions we will install the dhcpcd package and
ensure the service starts at boot. This service automatically sets
up all interfaces found via dhcp and/or dhcpv6 (or SLAAC).
Environment Variables
---------------------
DIB_DHCP_TIMEOUT
:Required: No
:Default: 30
:Description: Amount of time in seconds that the systemd service will
wait to get an address.
:Example: DIB_DHCP_TIMEOUT=300

View File

@ -24,6 +24,7 @@ if [ "$DIB_INIT_SYSTEM" == "upstart" ]; then
elif [ "$DIB_INIT_SYSTEM" == "systemd" ]; then
install -D -g root -o root -m 0644 ${SCRIPTDIR}/dhcp-interface@.service /usr/lib/systemd/system/dhcp-interface@.service
install -D -g root -o root -m 0644 ${SCRIPTDIR}/dhcp-all-interfaces-udev.rules /etc/udev/rules.d/99-dhcp-all-interfaces.rules
sed -i "s/TimeoutStartSec=DIB_DHCP_TIMEOUT/TimeoutStartSec=${DIB_DHCP_TIMEOUT:-30}s/" /usr/lib/systemd/system/dhcp-interface@.service
elif [ "$DIB_INIT_SYSTEM" == "sysv" ]; then
install -D -g root -o root -m 0755 ${SCRIPTDIR}/dhcp-all-interfaces.init /etc/init.d/dhcp-all-interfaces
update-rc.d dhcp-all-interfaces defaults

View File

@ -15,7 +15,7 @@ User=root
ExecStartPre=/usr/local/sbin/dhcp-all-interfaces.sh %I
ExecStart=/sbin/ifup %I
RemainAfterExit=true
TimeoutStartSec=30s
TimeoutStartSec=DIB_DHCP_TIMEOUT
[Install]
WantedBy=multi-user.target