Hi Bjørn, On Mon, 2021-04-12 at 14:27 +0200, Bjørn Mork wrote: > Mac adresses are assigned in the order given by the port list. The > interfaces are also brought up in this order. This target supports > devices with up to 52 ports. Sorting these alphabetically is very > confusing, and assigning mac addresses in alphabetic order does not > match stock firmware behaviour. > > There are probably better ways to do the numrical sorting, but this > was what I came up with... >
ls has the -v flag for numerical ("version") sorting: # ls lan0 lan1 lan10 lan2 # ls -v lan0 lan1 lan2 lan10 > Signed-off-by: Bjørn Mork <bj...@mork.no> > --- > target/linux/realtek/base-files/etc/board.d/02_network | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) > > diff --git a/target/linux/realtek/base-files/etc/board.d/02_network > b/target/linux/realtek/base-files/etc/board.d/02_network > index 44f1f0a7a5c1..06293174b0df 100644 > --- a/target/linux/realtek/base-files/etc/board.d/02_network > +++ b/target/linux/realtek/base-files/etc/board.d/02_network > @@ -17,10 +17,7 @@ ucidef_set_poe() { > board=$(board_name) > board_config_update > > -lan_list="" > -for lan in /sys/class/net/lan*; do > - lan_list="$lan_list $(basename $lan)" > -done > +lan_list=$(for lan in /sys/class/net/lan*; do echo > "${lan#/sys/class/net/lan}"; done|sort -n|sed -e 's/^/lan/'|xargs) So (unless my little test was bad) this can be shortened to: lan_list="$(ls -1 -v /sys/class/net/lan* | xargs -n1 basename)" Best, Sander _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel