updown.lua

来自「嵌入式无线路由系统openwrt的web配置工具」· LUA 代码 · 共 30 行

LUA
30
字号
#!/usr/bin/lua-- Copyright (C) 2008 OpenRB.comrequire('fslib')data = datajson() or {}-- check that ifname ('id' param) is suppliedif (data['id'] ~= nil) then  ifname = data['id']  -- check status  ifnames = proc('if-json -s')  up = (ifnames[ifname] == 1 and true or false)  -- convert ifname to uci config, ignore bridges  if ifname:find('^br--') ~= nil or ifname:find('^bond') ~= nil then    cfgname = nil  else    cfgname = iftocfg(ifname)  end  if (cfgname ~= nil) then    -- uci config is found, use built-in command    cmd = (up == true and 'ifdown ' .. cfgname or 'ifup ' .. cfgname)  else    -- otherwise, use ifconfig    cmd = 'ifconfig ' .. ifname .. (up == true and ' down' or ' up')  end  -- switch interface state  os.execute(cmd)end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?