2018-07-28 17:02:35 +00:00
|
|
|
-- Copyright 2017-2018 Dirk Brenken (dev@brenken.org)
|
2017-04-21 19:01:52 +00:00
|
|
|
-- This is free software, licensed under the Apache License, Version 2.0
|
|
|
|
|
2018-07-28 17:02:35 +00:00
|
|
|
local fs = require("nixio.fs")
|
|
|
|
local util = require("luci.util")
|
|
|
|
local input = "/etc/config/wireless"
|
2017-04-21 19:01:52 +00:00
|
|
|
|
2018-07-28 17:02:35 +00:00
|
|
|
if not fs.access(input) then
|
2017-04-21 19:01:52 +00:00
|
|
|
m = SimpleForm("error", nil, translate("Input file not found, please check your configuration."))
|
|
|
|
return m
|
|
|
|
end
|
|
|
|
|
|
|
|
m = SimpleForm("input", nil)
|
2018-11-14 10:43:39 +00:00
|
|
|
m:append(Template("travelmate/travelmate_css"))
|
2017-08-05 16:57:20 +00:00
|
|
|
m.submit = translate("Save")
|
2017-04-21 19:01:52 +00:00
|
|
|
m.reset = false
|
|
|
|
|
|
|
|
s = m:section(SimpleSection, nil,
|
|
|
|
translate("This form allows you to modify the content of the main wireless configuration file (/etc/config/wireless)."))
|
|
|
|
|
|
|
|
f = s:option(TextValue, "data")
|
|
|
|
f.rows = 20
|
|
|
|
f.rmempty = true
|
|
|
|
|
|
|
|
function f.cfgvalue()
|
2018-07-28 17:02:35 +00:00
|
|
|
return fs.readfile(input) or ""
|
2017-04-21 19:01:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function f.write(self, section, data)
|
2018-07-28 17:02:35 +00:00
|
|
|
return fs.writefile(input, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n")
|
|
|
|
end
|
|
|
|
|
|
|
|
function f.remove(self, section, value)
|
|
|
|
return fs.writefile(input, "")
|
2017-04-21 19:01:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function s.handle(self, state, data)
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
return m
|