aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files
diff options
context:
space:
mode:
authorJonas Gorski <jonas.gorski@gmail.com>2016-07-28 22:58:59 +0200
committerJonas Gorski <jonas.gorski@gmail.com>2016-08-13 15:50:00 +0200
commitc18edcec4500008a1dabf0b017322eb23b059c58 (patch)
treebebbcada227038049fccb60aafc2cb8c1faa7488 /package/base-files
parent0f1ae840c9c4a556e24709d5573ca7bdb8fc75ec (diff)
downloadupstream-c18edcec4500008a1dabf0b017322eb23b059c58.tar.gz
upstream-c18edcec4500008a1dabf0b017322eb23b059c58.tar.bz2
upstream-c18edcec4500008a1dabf0b017322eb23b059c58.zip
base-files: add preinit ifname detection based on board.json
Make use of the existing board.d to autodetect lan ifname in a generic way. Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Diffstat (limited to 'package/base-files')
-rw-r--r--package/base-files/files/lib/preinit/10_indicate_preinit29
1 files changed, 29 insertions, 0 deletions
diff --git a/package/base-files/files/lib/preinit/10_indicate_preinit b/package/base-files/files/lib/preinit/10_indicate_preinit
index b9368d90a9..206243390e 100644
--- a/package/base-files/files/lib/preinit/10_indicate_preinit
+++ b/package/base-files/files/lib/preinit/10_indicate_preinit
@@ -9,6 +9,33 @@ preinit_ip_config() {
ip -4 address add $pi_ip/$pi_netmask broadcast $pi_broadcast dev $1
}
+preinit_config_board() {
+ /bin/board_detect /tmp/board.json
+
+ [ -f "/tmp/board.json" ] || return
+
+ . /usr/share/libubox/jshn.sh
+
+ json_init
+ json_load "$(cat /tmp/board.json)"
+
+ json_select network
+ json_select "lan"
+ json_get_vars ifname
+ json_select ..
+ json_select ..
+
+ [ -n "$ifname" ] || return
+
+ # only use the first one
+ ifname=${ifname%% *}
+
+ # trim any vlan ids
+ ifname=${ifname%\.*}
+
+ preinit_ip_config $ifname
+}
+
preinit_ip() {
# if the preinit interface isn't specified and ifname is set in
# preinit.arch use that interface
@@ -18,6 +45,8 @@ preinit_ip() {
if [ -n "$pi_ifname" ]; then
preinit_ip_config $pi_ifname
+ elif [ -d "/etc/board.d/" ]; then
+ preinit_config_board
fi
}