* all options are full configurable via frontend * show current runtime information * show current travelmate logfile information * automatic wwan network interface setup (advanced section) * direct access to all relevant configuration files (advanced section) Signed-off-by: Dirk Brenken <dev@brenken.org>
55 lines
1.9 KiB
Lua
55 lines
1.9 KiB
Lua
-- Copyright 2017 Dirk Brenken (dev@brenken.org)
|
|
-- This is free software, licensed under the Apache License, Version 2.0
|
|
|
|
local nw = require("luci.model.network").init()
|
|
local fw = require("luci.model.firewall").init()
|
|
local util = require("luci.util")
|
|
local uci = require("luci.model.uci").cursor()
|
|
|
|
m = SimpleForm("network", translate("Interface Setup"),
|
|
translate("Automatically create a new wireless wan interface, configure it to use dhcp and " ..
|
|
"add it to the wan zone of the firewall. This step has only to be done once."))
|
|
m.reset = false
|
|
|
|
iface = m:field(Value, "netname", translate("Name of the new wireless wan interface"),
|
|
translate("The allowed characters are: <code>A-Z</code>, <code>a-z</code>, " ..
|
|
"<code>0-9</code> and <code>_</code> (3-15 characters)."))
|
|
iface.default = "wwan"
|
|
iface.datatype = "and(uciname,minlength(3),maxlength(15))"
|
|
|
|
function iface.validate(self, value, section)
|
|
local value = iface:formvalue(section)
|
|
local name = uci.get("network", value)
|
|
if name then
|
|
iface:add_error(section, translate("The given network interface name already exist"))
|
|
else
|
|
iface.datatype = false
|
|
iface.default = iface.disabled
|
|
f = m:field(DummyValue, "textfield", " ", translate("Direct Link: "
|
|
.. [[<a href="]] .. luci.dispatcher.build_url("admin/network/wireless") .. [[">]]
|
|
.. "Wireless Setup" .. [[</a>]]))
|
|
f.default = translate("Network Interface '" .. value .. "' created successfully." ..
|
|
" Feel free to scan & add new stations via standard wireless setup.")
|
|
f.disabled = true
|
|
end
|
|
return value
|
|
end
|
|
|
|
function iface.write(self, section, value)
|
|
local name = iface:formvalue(section)
|
|
if name then
|
|
local net = nw:add_network(name, { proto = "dhcp" })
|
|
if net then
|
|
nw:save("network")
|
|
nw:commit("network")
|
|
local zone = fw:get_zone_by_network("wan")
|
|
if zone then
|
|
zone:add_network(name)
|
|
fw:save("firewall")
|
|
fw:commit("firewall")
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
return m
|