aboutsummaryrefslogtreecommitdiff
path: root/init.d/net-online.in
diff options
context:
space:
mode:
authorMarcel Greter <marcel.greter@ocbnet.ch>2017-12-09 23:18:03 +0100
committerWilliam Hubbs <w.d.hubbs@gmail.com>2017-12-11 14:46:16 -0600
commit5c81661d4758dea039860ae2481476a70e78ac47 (patch)
tree4f1c03642553914f30b93dbfa4d501ba26112d66 /init.d/net-online.in
parentfb96c9c127dcfa932460b0e8a977ba5f7d26a418 (diff)
Gracefully handle unreadable /sys/class/net/dev/ nodes
Fixes https://bugs.gentoo.org/629228 Fixes #189 Fixes #185 Fixes #178
Diffstat (limited to 'init.d/net-online.in')
-rw-r--r--init.d/net-online.in10
1 files changed, 5 insertions, 5 deletions
diff --git a/init.d/net-online.in b/init.d/net-online.in
index 45041c80..41910fa0 100644
--- a/init.d/net-online.in
+++ b/init.d/net-online.in
@@ -31,7 +31,7 @@ get_interfaces()
start ()
{
local carriers configured dev gateway ifcount infinite
- local rc state x
+ local carrier operstate rc
ebegin "Checking to see if the network is online"
rc=0
@@ -44,10 +44,10 @@ start ()
ifcount=0
for dev in ${interfaces}; do
: $((ifcount += 1))
- read x < /sys/class/net/$dev/carrier
- [ $x -eq 1 ] && : $((carriers += 1))
- read x < /sys/class/net/$dev/operstate
- [ "$x" = up ] && : $((configured += 1))
+ read carrier < /sys/class/net/$dev/carrier 2> /dev/null
+ [ $carrier -eq 1 ] && : $((carriers += 1))
+ read operstate < /sys/class/net/$dev/operstate 2> /dev/null
+ [ "$operstate" = up ] && : $((configured += 1))
done
[ $configured -eq $ifcount ] && [ $carriers -ge 1 ] && break
sleep 1