Skip to content
This repository was archived by the owner on Jan 16, 2024. It is now read-only.

Commit 381b5b1

Browse files
committed
M #-: Avoid slow contextualization
1 parent 7324b69 commit 381b5b1

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

src/etc/one-context.d/loc-10-network.d/netcfg-networkd

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,13 @@ gen_network_configuration()
269269
{
270270
_context_interfaces=$(get_context_interfaces)
271271

272+
_networkd_version=$(networkctl --version | head -1 | awk '{print $2}')
273+
274+
if [ -n "$_networkd_version" ]; then
275+
# put some dummy low version if not detected
276+
_networkd_version="100"
277+
fi
278+
272279
for _iface in $_context_interfaces; do
273280
setup_iface_vars "$_iface"
274281

@@ -286,12 +293,16 @@ gen_network_configuration()
286293
#
287294
# This occurs at least with systemd/networkd version 248, which is on
288295
# Cent OS 8 for example.
289-
if is_networkd_iface_managed "${dev}" ; then
290-
# networkctl up/down is not on ubuntu <21.04
291-
networkctl down "$dev" 2>/dev/null || true
292296

293-
# this is still necessary to really unconfigure the interface
294-
ip addr flush "$dev"
297+
298+
if [ $_networkd_version -le 250 ]; then
299+
if is_networkd_iface_managed "${dev}" ; then
300+
# networkctl up/down is not on ubuntu <21.04
301+
networkctl down "$dev" 2>/dev/null || true
302+
303+
# this is still necessary to really unconfigure the interface
304+
ip addr flush "$dev"
305+
fi
295306
fi
296307

297308
{

0 commit comments

Comments
 (0)