gluon-core: don't call 'ip' to check if an interface exists

This commit is contained in:
Matthias Schiffer 2017-04-11 02:01:21 +02:00
parent c4613c4e8d
commit 02f2d8796c
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C

View File

@ -12,6 +12,7 @@ local util = require 'gluon.util'
local platform = require 'gluon.platform' local platform = require 'gluon.platform'
local site = require 'gluon.site_config' local site = require 'gluon.site_config'
local fs = require 'nixio.fs'
local uci = require('simple-uci').cursor() local uci = require('simple-uci').cursor()
@ -19,7 +20,7 @@ local function iface_exists(ifaces)
if not ifaces then return nil end if not ifaces then return nil end
for iface in ifaces:gmatch('%S+') do for iface in ifaces:gmatch('%S+') do
if util.exec('ip', 'link', 'show', 'dev', (iface:gsub('%..*$', ''))) == 0 then if fs.access('/sys/class/net/' .. iface:gsub('%..*$', '')) then
return ifaces return ifaces
end end
end end