This allows custom config generation.
E.g. setting lan adrress from eeprom or random address
(so that routers can be chained by default) or configuring
a fully custom interface.

Signed-off-by: Roman Yeryomin <ro...@advem.lv>
---
 .../base-files/files/lib/functions/uci-defaults.sh | 26 +++++++++++++++++++++-
 .../linux/ar71xx/base-files/etc/board.d/02_network |  4 ++--
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/package/base-files/files/lib/functions/uci-defaults.sh 
b/package/base-files/files/lib/functions/uci-defaults.sh
index 82ac1d2a4d..0cd519a147 100755
--- a/package/base-files/files/lib/functions/uci-defaults.sh
+++ b/package/base-files/files/lib/functions/uci-defaults.sh
@@ -88,8 +88,32 @@ ucidef_set_interfaces_lan_wan() {
 }
 
 ucidef_set_interface_raw() {
+       local opt=";"
+       local val=""
+
+       [ -z "$1" ] && return
+
        json_select_object network
-       _ucidef_set_interface "$@"
+
+       for i in "$@"; do
+               [ "$opt" == ";" ] && {
+                       json_select_object "$i"
+                       opt=""
+                       continue
+               }
+               [ -z $opt ] && {
+                       opt="$i"
+                       continue
+               }
+               [ -z $val ] && val="$i"
+
+               json_add_string "$opt" "$val"
+
+               opt=""
+               val=""
+       done
+
+       json_select ..
        json_select ..
 }
 
diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network 
b/target/linux/ar71xx/base-files/etc/board.d/02_network
index 7cf4212ac7..f6c7c90738 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/02_network
+++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
@@ -427,7 +427,7 @@ ar71xx_setup_interfaces()
                ;;
        tellstick-znet-lite)
                ucidef_set_interface_wan "eth0"
-               ucidef_set_interface_raw "wlan" "wlan0" "dhcp"
+               ucidef_set_interface_raw "wlan" iface "wlan0" proto "dhcp"
                ;;
        tl-mr3420-v2|\
        tl-wr841n-v8|\
@@ -458,7 +458,7 @@ ar71xx_setup_interfaces()
                ;;
        tl-wr841n-v1|\
        tl-wr941nd)
-               ucidef_set_interface_raw "eth" "eth0"
+               ucidef_set_interface_raw "eth" iface "eth0"
                ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
                ;;
        tl-wr741nd|\
-- 
2.14.1


_______________________________________________
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev

Reply via email to