[openwrt/openwrt] base-files: simplify setting device MAC
LEDE Commits
lede-commits at lists.infradead.org
Fri May 28 07:04:21 PDT 2021
rmilecki pushed a commit to openwrt/openwrt.git, branch openwrt-21.02:
https://git.openwrt.org/c2139eef279ef9efc30ddbaf08544f33eac63e36
commit c2139eef279ef9efc30ddbaf08544f33eac63e36
Author: Rafał Miłecki <rafal at milecki.pl>
AuthorDate: Fri May 28 08:18:08 2021 +0200
base-files: simplify setting device MAC
1. Move code above interface generation
It results in more logical order. Device gets its config section
above interface section.
2. Drop the loop
We have separated code handling bridges now so $device should be
guaranteed to contain a single device name.
3. Drop section name
It's not required by netifd or LuCI & it's not needed by this script
as $device contains a single device name now.
Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
(cherry picked from commit e002179a6d2eea8640e262160030336bea54ec26)
---
package/base-files/files/bin/config_generate | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate
index d895090309..0dca5549e8 100755
--- a/package/base-files/files/bin/config_generate
+++ b/package/base-files/files/bin/config_generate
@@ -133,6 +133,14 @@ generate_network() {
type=""
}
+ if [ -n "$macaddr" ]; then
+ uci -q batch <<-EOF
+ add network device
+ set network. at device[-1].name='$device'
+ set network. at device[-1].macaddr='$macaddr'
+ EOF
+ fi
+
uci -q batch <<-EOF
delete network.$1
set network.$1='interface'
@@ -141,17 +149,6 @@ generate_network() {
set network.$1.proto='none'
EOF
- if [ -n "$macaddr" ]; then
- for name in $device; do
- uci -q batch <<-EOF
- delete network.$1_${name/./_}_dev
- set network.$1_${name/./_}_dev='device'
- set network.$1_${name/./_}_dev.name='$name'
- set network.$1_${name/./_}_dev.macaddr='$macaddr'
- EOF
- done
- fi
-
case "$protocol" in
static)
local ipad
More information about the lede-commits
mailing list