sortnetif: reduce code

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium 2024-10-25 18:24:09 +02:00
parent f5c6f6ccf1
commit 2d2bc8b388
2 changed files with 2 additions and 10 deletions

View File

@ -16,16 +16,8 @@ if [ "${1}" = "patches" ]; then
BUS="$(ethtool -i ${ETH} 2>/dev/null | grep bus-info | cut -d' ' -f2)"
ETHLIST="${ETHLIST}${BUS} ${MAC} ${ETH}\n"
done
ETHLISTTMPM=""
ETHLISTTMPB="$(echo -e "${ETHLIST}" | sort)"
if [ -n "${2}" ]; then
MACS="$(echo "${2}" | sed 's/://g; s/,/ /g; s/.*/\L&/')"
for MACX in ${MACS}; do
ETHLISTTMPM="${ETHLISTTMPM}$(echo -e "${ETHLISTTMPB}" | grep "${MACX}")\n"
ETHLISTTMPB="$(echo -e "${ETHLISTTMPB}" | grep -v "${MACX}")\n"
done
fi
ETHLIST="$(echo -e "${ETHLISTTMPM}${ETHLISTTMPB}" | grep -v '^$')"
ETHLIST="$(echo -e "${ETHLISTTMPB}" | grep -v '^$')"
ETHSEQ="$(echo -e "${ETHLIST}" | awk '{print $3}' | sed 's/eth//g')"
ETHNUM="$(echo -e "${ETHLIST}" | wc -l)"

View File

@ -1,6 +1,6 @@
version: 1
name: sortnetif
description: "Sort network interface names | empty: sorted by busid; mac1,mac2,...: sorted by macs sequence"
description: "Sort network interface names: sorted by busid"
system: false
beta: false
target: system