summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-mwan3/luasrc/model/cbi/mwan/advanced_mwanconfig.lua
blob: e0a99e8366853aac24b19d04bf6f0ccbf8eea9a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
-- ------ mwan configuration ------ --

ut = require "luci.util"

mwanConfig = "/etc/config/mwan3"


m5 = SimpleForm("luci", nil)
	m5:append(Template("mwan/advanced_mwanconfig")) -- highlight current tab


f = m5:section(SimpleSection, nil,
	translate("This section allows you to modify the contents of /etc/config/mwan3"))

t = f:option(TextValue, "lines")
	t.rmempty = true
	t.rows = 20

	function t.cfgvalue()
		return nixio.fs.readfile(mwanConfig) or ""
	end

	function t.write(self, section, data) -- format and write new data to script
		return nixio.fs.writefile(mwanConfig, "\n" .. ut.trim(data:gsub("\r\n", "\n")) .. "\n")
	end

	function f.handle(self, state, data)
		return true
	end


return m5