From 11d91501d0c369b918f615d66d1ba4681847ef4a Mon Sep 17 00:00:00 2001 From: Olivier Bourdon Date: Thu, 19 Apr 2018 12:00:13 +0200 Subject: [PATCH] Fix /etc/network/interfaces file contents According to http://bit.ly/2HA4oDO and the official Ubuntu manual http://manpages.ubuntu.com/manpages/xenial/man5/interfaces.5.html source-dir support has been removed from Ubuntu >= 16.04/Xenial Once an image is generated and booted, moving the dhcp interface(s) declaration(s) from /etc/network/interfaces into specific subentries of /etc/network/interfaces.d and calling 'service networking restart' just make your instance unreachable and all interfaces are left unconfigured. This patchset fixes this issue Change-Id: I6b6b99c81490c874c5db5405c2fbf3c180c87464 --- .../install.d/60-remove-cloud-image-interfaces | 6 +++++- .../simple-init/install.d/60-simple-init-remove-interfaces | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/diskimage_builder/elements/dhcp-all-interfaces/install.d/60-remove-cloud-image-interfaces b/diskimage_builder/elements/dhcp-all-interfaces/install.d/60-remove-cloud-image-interfaces index e3a7b795..1109fccd 100755 --- a/diskimage_builder/elements/dhcp-all-interfaces/install.d/60-remove-cloud-image-interfaces +++ b/diskimage_builder/elements/dhcp-all-interfaces/install.d/60-remove-cloud-image-interfaces @@ -25,6 +25,10 @@ rm -f /etc/conf.d/net* if [ -f "/etc/network/interfaces" ]; then printf "auto lo\niface lo inet loopback\n\n" > /etc/network/interfaces if [ -d "/etc/network/interfaces.d/" ]; then - printf "source-directory interfaces.d\n\n" >> /etc/network/interfaces + if [ "$DISTRO_NAME" == "ubuntu" ] && [ "$DIB_RELEASE" == "trusty" ]; then + printf "source-directory interfaces.d\n\n" >> /etc/network/interfaces + else + printf "source /etc/network/interfaces.d/*\n\n" >> /etc/network/interfaces + fi fi fi diff --git a/diskimage_builder/elements/simple-init/install.d/60-simple-init-remove-interfaces b/diskimage_builder/elements/simple-init/install.d/60-simple-init-remove-interfaces index 5e47a854..8d21932e 100755 --- a/diskimage_builder/elements/simple-init/install.d/60-simple-init-remove-interfaces +++ b/diskimage_builder/elements/simple-init/install.d/60-simple-init-remove-interfaces @@ -28,6 +28,10 @@ rm -f /etc/conf.d/net* if [ -f "/etc/network/interfaces" ]; then printf "auto lo\niface lo inet loopback\n\n" > /etc/network/interfaces if [ -d "/etc/network/interfaces.d/" ]; then - printf "source-directory interfaces.d\n\n" >> /etc/network/interfaces + if [ "$DISTRO_NAME" == "ubuntu" ] && [ "$DIB_RELEASE" == "trusty" ]; then + printf "source-directory interfaces.d\n\n" >> /etc/network/interfaces + else + printf "source /etc/network/interfaces.d/*\n\n" >> /etc/network/interfaces + fi fi fi