- btn = s:option(Button, "", translate("Create Uplink Interface"),
- translate("Create a new wireless wan uplink interface, configure it to use dhcp and ")
- .. translate("add it to the wan zone of the firewall. This step has only to be done once."))
- btn.inputtitle = translate("Add Interface")
- btn.inputstyle = "apply"
- btn.disabled = false
- function btn.write(self, section, value)
- iface = o:formvalue(section)
- uci:set("travelmate", section, "trm_iface", iface)
- uci:save("travelmate")
- uci:commit("travelmate")
- local net = nw:add_network(iface, { 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(iface)
- fw:save("firewall")
- fw:commit("firewall")
- luci.sys.call("env -i /bin/ubus call network reload >/dev/null 2>&1")
+ function o.validate(self, value)
+ if value then
+ local nwnet = nw:get_network(value)
+ local zone = fw:get_zone("wan")
+ local fwnet = fw:get_zone_by_network(value)
+ if not nwnet then
+ nwnet = nw:add_network(value, { proto = "dhcp" })
+ end
+ if zone and not fwnet then
+ fwnet = zone:add_network(value)