Merge "Change DHCP timeout"

This commit is contained in:
Zuul 2020-06-04 23:19:22 +00:00 committed by Gerrit Code Review
commit 2859569635
3 changed files with 34 additions and 0 deletions

View File

@ -27,6 +27,9 @@ MANILA_IMG_NAME=${MANILA_IMG_NAME:-"manila-service-image"}
MANILA_SHARE_PROTO=${MANILA_SHARE_PROTO:-"default"}
MANILA_DISTRO=${MANILA_DISTRO:-"ubuntu"}
#Misc settings
DHCP_TIMEOUT=${DHCP_TIMEOUT:-"300"}
# Path to elements
SCRIPT_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@ -47,6 +50,7 @@ export DIB_RELEASE=$MANILA_IMG_OS_VER
export DIB_MANILA_USER_USERNAME=$MANILA_USER
export DIB_MANILA_USER_PASSWORD=$MANILA_PASSWORD
export DIB_MANILA_USER_AUTHORIZED_KEYS=$MANILA_USER_AUTHORIZED_KEYS
export DIB_DHCP_TIMEOUT=$DHCP_TIMEOUT
# CLI
# ---

View File

@ -0,0 +1,2 @@
#!/bin/bash
export DIB_DHCP_TIMEOUT=${DIB_DHCP_TIMEOUT:-300}

View File

@ -0,0 +1,28 @@
#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
DHCP_TIMEOUT=${DIB_DHCP_TIMEOUT:-300}
if [ -f /etc/dhcp/dhclient.conf ] ; then
# Set the dhclient timeout configurations to match DIB_DHCP_TIMEOUT,
if grep -o "^timeout " /etc/dhcp/dhclient.conf ; then
sed -i -e "s/^timeout .*/# \"timeout\" Value set by 99-update-dhcp-config\ntimeout ${DHCP_TIMEOUT};/" /etc/dhcp/dhclient.conf
else
echo -e "# \"timeout\" Value set by 99-update-dhcp-config\ntimeout ${DHCP_TIMEOUT};" >> /etc/dhcp/dhclient.conf
fi
fi
DIB_INIT_SYSTEM=$(dib-init-system)
if [ "$DIB_INIT_SYSTEM" == "systemd" ] ; then
sudo cp /usr/lib/systemd/system/dhcp-interface@.service \
/etc/systemd/system/dhcp-interface@.service
sudo sed -i "s/TimeoutStartSec=.*/TimeoutStartSec=${DHCP_TIMEOUT}s/" \
/etc/systemd/system/dhcp-interface@.service
else
echo "Not supported for this init system"
fi