diff --git a/bin/manila-image-create b/bin/manila-image-create index b741736..1d5da51 100755 --- a/bin/manila-image-create +++ b/bin/manila-image-create @@ -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 # --- diff --git a/elements/manila-ssh/environment.d/99-update-dhcp-config b/elements/manila-ssh/environment.d/99-update-dhcp-config new file mode 100755 index 0000000..c73d6e8 --- /dev/null +++ b/elements/manila-ssh/environment.d/99-update-dhcp-config @@ -0,0 +1,2 @@ +#!/bin/bash +export DIB_DHCP_TIMEOUT=${DIB_DHCP_TIMEOUT:-300} diff --git a/elements/manila-ssh/install.d/99-update-dhcp-config b/elements/manila-ssh/install.d/99-update-dhcp-config new file mode 100755 index 0000000..d673c86 --- /dev/null +++ b/elements/manila-ssh/install.d/99-update-dhcp-config @@ -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