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

Commit

Permalink
M #-: Avoid slow contextualization
Browse files Browse the repository at this point in the history
  • Loading branch information
xorel committed Dec 27, 2022
1 parent 7324b69 commit 381b5b1
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/etc/one-context.d/loc-10-network.d/netcfg-networkd
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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

{
Expand Down

0 comments on commit 381b5b1

Please sign in to comment.