Use systemd-networkd for debian

Moving from networking to systemd-networkd for debian
Original networking is not capable to natively manage down/up on
interfaces that is necessary for rescue

Change-Id: Ia6e2f217bd3222641cc1c97931e776e7fb717755
This commit is contained in:
Damien Rannou 2023-10-18 10:59:32 +02:00
parent 612ce753c5
commit 112157b1a9
1 changed files with 19 additions and 0 deletions

View File

@ -7,6 +7,7 @@ set -eu
set -o pipefail
DIB_IPA_ENABLE_RESCUE=${DIB_IPA_ENABLE_RESCUE:-true}
DIB_IPA_ENABLE_SYSTEMD_NETWORKD=${DIB_IPA_ENABLE_SYSTEMD_NETWORKD:-true}
if $DIB_IPA_ENABLE_RESCUE; then
# Make sure rescue works
@ -42,6 +43,24 @@ case "$DIB_INIT_SYSTEM" in
systemctl disable dnf-makecache.timer
fi
fi
# NOTE(drannou) debian by default is using networking instead of
# systemd-networkd. In some usecase like rescue, we need IPA to
# re-launch dhclient when modifications are made on the interface.
# The easiest way to manage that is to activate systemd-networkd.
if $DIB_IPA_ENABLE_SYSTEMD_NETWORKD; then
if [[ $DISTRO_NAME =~ debian ]] ; then
rm /etc/network/interfaces
rm -rf /etc/network/interfaces.d
echo "[Match]
Name=en*
[Network]
DHCP=yes" > /etc/systemd/network/99-dhcp.network
systemctl enable systemd-networkd
fi
fi
;;
sysv)
update-rc.d iptables disable