save.lua

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

LUA
34
字号
#!/usr/bin/lua-- Copyright (C) 2008 OpenRB.comrequire('fslib')data = datajson()-- check data, id and values are passedif (data ~= nil and data['values'] ~= nil) then  file = 'ssmtp'  uci.init(file, file, file)  for field, value in pairs(data['values']) do    uci.setvalue(file, data['id'], field, value)  end  uci.commit(file)end-- convert to plain text formatf = io.open('/etc/ssmtp/ssmtp.conf', 'w')cfg = uci.init(file, file, file)-- file is ready for writing and there are some config values setif (f ~= nil and cfg ~= nil) then  fields = {'root', 'Mailhub', 'AuthUser', 'AuthPass', 'Hostname', 'UseTLS', 'UseSTARTTLS'}    for i, field in ipairs(fields) do    if (cfg[field] ~= nil) then      f:write(field .. '=' .. cfg[field], "\n")    end  end    f:close()end

⌨️ 快捷键说明

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