oxnas: rework 02_network
authorSungbo Eo <mans0n@gorani.run>
Sun, 15 Mar 2020 17:42:38 +0000 (02:42 +0900)
committerSungbo Eo <mans0n@gorani.run>
Mon, 16 Mar 2020 08:16:39 +0000 (17:16 +0900)
Just like other targets do, introduce two setup functions for interfaces and
MAC addresses.

Signed-off-by: Sungbo Eo <mans0n@gorani.run>
target/linux/oxnas/base-files/etc/board.d/02_network

index 7b657cd108cc6e09b9b1f57c0e117cf4d8268099..9ba2deb7b4213f2f275a9716f97dd5f5ccfbb433 100755 (executable)
@@ -3,10 +3,6 @@
 . /lib/functions/uci-defaults.sh
 . /lib/functions/system.sh
 
-board_config_update
-
-lan_mac=""
-
 bootloader_cmdline_var() {
        local param
        local pval
@@ -31,15 +27,35 @@ legacy_boot_mac_adr() {
        IFS="$oIFS"
 }
 
-case "$(board_name)" in
-       "shuttle,kd20")
+oxnas_setup_interfaces()
+{
+       local board="$1"
+
+       case $board in
+       *)
+               ucidef_set_interface_lan "eth0" "dhcp"
+               ;;
+       esac
+}
+
+oxnas_setup_macs()
+{
+       local board="$1"
+       local lan_mac=""
+
+       case $board in
+       shuttle,kd20)
                lan_mac="$(legacy_boot_mac_adr)"
                ;;
-esac
+       esac
 
-ucidef_set_interface_lan "eth0" "dhcp"
-[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" "$lan_mac"
+       [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
+}
 
+board_config_update
+board=$(board_name)
+oxnas_setup_interfaces $board
+oxnas_setup_macs $board
 board_config_flush
 
 exit 0