Fix install shim ethernet detect fail
"ip -f inet addr" shows extra message
"valid_lft forever preferred_lft forever".
So there are three lines output and cannot fit
"sed 'N;s/\n/ /'" command.
The sed command is to merge lines two by two.
we use another way to check usable ethernet.
BUG=chrome-os-partner:24903
TEST=manaully test on DUT
Change-Id: I2d5a59fdfc6cbadbe2fc2740a32455dfd5e19201
Reviewed-on: https://chromium-review.googlesource.com/181884
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Commit-Queue: Heng-ruey Hsu <henryhsu@google.com>
Tested-by: Heng-ruey Hsu <henryhsu@google.com>
diff --git a/factory_install.sh b/factory_install.sh
index 236c1a3..3024ee2 100644
--- a/factory_install.sh
+++ b/factory_install.sh
@@ -161,20 +161,16 @@
}
check_ethernet_status() {
- local link inet
- local i j
+ local link i
link=$(ip -f link addr | sed 'N;s/\n/ /' | grep -w 'ether' |
cut -d ' ' -f 2 | sed 's/://')
- inet=$(ip -f inet addr | sed 'N;s/\n/ /' | cut -d ' ' -f 2 | sed 's/://')
for i in $link; do
- for j in $inet; do
- if [ "$i" = "$j" ]; then
- if ! iw $i info >/dev/null 2>&1; then
- log "$(ip -f inet addr show $i | grep inet)"
- return 0
- fi
+ if ip -f inet addr show $i | grep -q inet; then
+ if ! iw $i info >/dev/null 2>&1; then
+ log "$(ip -f inet addr show $i | grep inet)"
+ return 0
fi
- done
+ fi
done
return 1
}