restart.lua

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

LUA
36
字号
#!/usr/bin/lua-- Copyright (C) 2008 OpenRB.comrequire('fslib')data = datajson()-- config name must be suppliedif (data ~= nil and data['id'] ~= nil) then  cfgname = data['id']  cfg = uci.get_all('network', cfgname)  if (cfg['type'] == 'bridge') then    ifname = 'br-' .. cfgname    forcedown = true  else    ifname = cfg['ifname']  end  -- interface found, check if it's up  if (ifname ~= nil) then    ifstats = proc('if-json -s')        -- interface is up, restart it    if (ifstats[ ifname ] == 1) then      if (forcedown) then        os.execute('ifdown ' .. cfgname)      end      os.execute('ifup ' .. cfgname)      -- has wireless, restart it aswell      if (cfgname:find('^wifi')) then        os.execute('wifi ' .. cfgname)      end    end  endend

⌨️ 快捷键说明

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