📄 updown.lua
字号:
#!/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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -