summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-mwan3/luasrc/model/cbi
diff options
context:
space:
mode:
authorHannu Nyman <hannu.nyman@iki.fi>2017-08-16 18:42:59 +0300
committerGitHub <noreply@github.com>2017-08-16 18:42:59 +0300
commit209deb50a41664c4a3a04b92d9d36b935792e477 (patch)
treeae05d5623a1faefa5838f6d5d96620575912bf84 /applications/luci-app-mwan3/luasrc/model/cbi
parentdff56b96dc22a7796430010244ddff5091345427 (diff)
parent6c4053066a56e85b3d2420d1183916598cdcd400 (diff)
Merge pull request #1308 from TDT-GmbH/luci-app-mwan3_update
luci-app-mwan3: use mwan3.user and add global mmx_mask option
Diffstat (limited to 'applications/luci-app-mwan3/luasrc/model/cbi')
-rw-r--r--applications/luci-app-mwan3/luasrc/model/cbi/mwan/advanced_hotplugscript.lua51
-rw-r--r--applications/luci-app-mwan3/luasrc/model/cbi/mwan/globalsconfig.lua8
2 files changed, 26 insertions, 33 deletions
diff --git a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/advanced_hotplugscript.lua b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/advanced_hotplugscript.lua
index 0e7b8b11d0..1b97080216 100644
--- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/advanced_hotplugscript.lua
+++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/advanced_hotplugscript.lua
@@ -1,55 +1,40 @@
-- ------ hotplug script configuration ------ --
fs = require "nixio.fs"
-sys = require "luci.sys"
ut = require "luci.util"
-script = "/etc/hotplug.d/iface/16-mwancustom"
-scriptBackup = "/etc/hotplug.d/iface/16-mwancustombak"
-
-if luci.http.formvalue("cbid.luci.1._restorebak") then -- restore button has been clicked
- luci.http.redirect(luci.dispatcher.build_url("admin/network/mwan/advanced/hotplugscript") .. "?restore=yes")
-elseif luci.http.formvalue("restore") == "yes" then -- restore script from backup
- os.execute("cp -f " .. scriptBackup .. " " .. script)
-end
-
+script = "/etc/mwan3.user"
m5 = SimpleForm("luci", nil)
m5:append(Template("mwan/advanced_hotplugscript")) -- highlight current tab
f = m5:section(SimpleSection, nil,
- translate("This section allows you to modify the contents of /etc/hotplug.d/iface/16-mwancustom<br />" ..
- "This is useful for running system commands and/or scripts based on interface ifup or ifdown hotplug events<br /><br />" ..
+ translate("This section allows you to modify the content of \"/etc/mwan3.user\".<br />" ..
+ "The file is also preserved during sysupgrade.<br />" ..
+ "<br />" ..
"Notes:<br />" ..
- "The first line of the script must be &#34;#!/bin/sh&#34; without quotes<br />" ..
- "Lines beginning with # are comments and are not executed<br /><br />" ..
- "Available variables:<br />" ..
- "$ACTION is the hotplug event (ifup, ifdown)<br />" ..
- "$INTERFACE is the interface name (wan1, wan2, etc.)<br />" ..
- "$DEVICE is the device name attached to the interface (eth0.1, eth1, etc.)"))
-
-
-restore = f:option(Button, "_restorebak", translate("Restore default hotplug script"))
- restore.inputtitle = translate("Restore...")
- restore.inputstyle = "apply"
+ "This file is interpreted as a shell script.<br />" ..
+ "The first line of the script must be &#34;#!/bin/sh&#34; without quotes.<br />" ..
+ "Lines beginning with # are comments and are not executed.<br />" ..
+ "Put your custom mwan3 action here, they will<br />" ..
+ "be executed with each netifd hotplug interface event<br />" ..
+ "on interfaces for which mwan3 is enabled.<br />" ..
+ "<br />" ..
+ "There are three main environment variables that are passed to this script.<br />" ..
+ "<br />" ..
+ "$ACTION Either \"ifup\" or \"ifdown\"<br />" ..
+ "$INTERFACE Name of the interface which went up or down (e.g. \"wan\" or \"wwan\")<br />" ..
+ "$DEVICE Physical device name which interface went up or down (e.g. \"eth0\" or \"wwan0\")<br />" ..
+ "<br />"))
t = f:option(TextValue, "lines")
t.rmempty = true
t.rows = 20
-
function t.cfgvalue()
- local hps = fs.readfile(script)
- if not hps or hps == "" then -- if script does not exist or is blank restore from backup
- sys.call("cp -f " .. scriptBackup .. " " .. script)
- return fs.readfile(script)
- else
- return hps
- end
+ return fs.readfile(script)
end
-
function t.write(self, section, data) -- format and write new data to script
return fs.writefile(script, ut.trim(data:gsub("\r\n", "\n")) .. "\n")
end
-
return m5
diff --git a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/globalsconfig.lua b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/globalsconfig.lua
index 54d20bdcb5..919ed46cd4 100644
--- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/globalsconfig.lua
+++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/globalsconfig.lua
@@ -29,4 +29,12 @@ for _, net in ipairs(net:get_networks()) do
end
n.rmempty = false
+mask = s:option(
+ Value,
+ "mmx_mask",
+ translate("Firewall mask"),
+ translate("Enter value in hex, starting with <code>0x</code>"))
+mask.datatype = "hex(4)"
+mask.default = "0xff00"
+
return m