formcustom.lua

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

LUA
35
字号
#!/usr/bin/lua-- Copyright (C) 2008 OpenRB.comrequire('fslib')cfgvars = {  values = {    custom = ''  },  params = {    id = 'custom',    path = '/etc/firewall.user'  }}cfg = uci.init('firewall', 'custom', 'include', true)-- read include path from configif (type(cfg) == 'table') then  if (cfg['path'] ~= nil) then    cfgvars.params.path = cfg['path']  end-- no config entry found, set defaultselse  uci.set('firewall', 'custom', 'path', cfgvars.params.path)  uci.commit('firewall')end-- make sure custom config file existsos.execute('touch ' .. cfgvars.params.path)-- skip first linecfgvars.values.custom = table.concat(readlines(cfgvars.params.path, 1), "\n");io.write(json.encode(cfgvars))

⌨️ 快捷键说明

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