diskimage-builder/diskimage_builder/elements/simple-init/install.d/60-simple-init-remove-interfaces
Dmitry Tantsur 1462b80781 simple-init: also remove en* interfaces from the images
Modern distros use more creative interface naming, e.g. CentOS 8
adds both eth0 and ens3 (!). Remove everything.

Change-Id: Ibdebdb09ea790787840cf9b817d4eb549ef18249
2020-11-22 20:17:42 +01:00

37 lines
984 B
Bash
Executable file

#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# Cloud images may hard code the eth0/ens* interfaces so they
# boot with DHCP.
# Fedora
rm -f /etc/sysconfig/network-scripts/ifcfg-eth*
rm -f /etc/sysconfig/network-scripts/ifcfg-en*
# SUSE
rm -f /etc/sysconfig/network/ifcfg-eth*
rm -f /etc/sysconfig/network/ifcfg-en*
# Ubuntu and Debian
rm -f /etc/network/interfaces.d/eth*
rm -f /etc/network/interfaces.d/en*
# Gentoo
rm -f /etc/conf.d/net*
# /etc/network/interfaces distributions
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
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