From 120e87ac99a4fdc69ebf348c92167ac5b6062938 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 26 Oct 2023 17:56:10 +0200 Subject: [PATCH] confd: sort interfaces according to length and name A list of interfaces: x10 x9 x8 x7 x6 x5 x4 x1 x2 x3 should be sorted in order with x10 last. Using the common 'sort -n' would generate: x1 x10 x2 ... so we use version sort. This way we can ensure that the order of bridge ports is natural and what end users expect. Signed-off-by: Joachim Wiberg --- src/confd/bin/gen-interfaces | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/confd/bin/gen-interfaces b/src/confd/bin/gen-interfaces index d3611eba..b7c4c9a3 100755 --- a/src/confd/bin/gen-interfaces +++ b/src/confd/bin/gen-interfaces @@ -85,13 +85,13 @@ phys_ifaces=$(ip -d -j link show | jq -r ' select(.link_type == "ether") | select(.group != "internal") | select(has("parentbus")) | - .ifname') + .ifname' | sort -V) ports=$(ip -d -j link show group port | jq -r ' .[] | select(.link_type == "ether") | select(.group != "internal") | select(has("parentbus")) | - .ifname') + .ifname' | sort -V) ifaces="" for phy in $phys_ifaces; do found=""