From 381b5b10da426b8351481652ca23eef867ab2796 Mon Sep 17 00:00:00 2001 From: Jan Orel Date: Thu, 22 Dec 2022 16:50:17 +0100 Subject: [PATCH] M #-: Avoid slow contextualization --- .../loc-10-network.d/netcfg-networkd | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/etc/one-context.d/loc-10-network.d/netcfg-networkd b/src/etc/one-context.d/loc-10-network.d/netcfg-networkd index 825ac96..daf36b0 100644 --- a/src/etc/one-context.d/loc-10-network.d/netcfg-networkd +++ b/src/etc/one-context.d/loc-10-network.d/netcfg-networkd @@ -269,6 +269,13 @@ gen_network_configuration() { _context_interfaces=$(get_context_interfaces) + _networkd_version=$(networkctl --version | head -1 | awk '{print $2}') + + if [ -n "$_networkd_version" ]; then + # put some dummy low version if not detected + _networkd_version="100" + fi + for _iface in $_context_interfaces; do setup_iface_vars "$_iface" @@ -286,12 +293,16 @@ gen_network_configuration() # # This occurs at least with systemd/networkd version 248, which is on # Cent OS 8 for example. - if is_networkd_iface_managed "${dev}" ; then - # networkctl up/down is not on ubuntu <21.04 - networkctl down "$dev" 2>/dev/null || true - # this is still necessary to really unconfigure the interface - ip addr flush "$dev" + + if [ $_networkd_version -le 250 ]; then + if is_networkd_iface_managed "${dev}" ; then + # networkctl up/down is not on ubuntu <21.04 + networkctl down "$dev" 2>/dev/null || true + + # this is still necessary to really unconfigure the interface + ip addr flush "$dev" + fi fi {