-- ------ hotplug script configuration ------ --
fs = require "nixio.fs"
ut = require "luci.util"
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 content of \"/etc/mwan3.user\".
" ..
"The file is also preserved during sysupgrade.
" ..
"
" ..
"Notes:
" ..
"This file is interpreted as a shell script.
" ..
"The first line of the script must be "#!/bin/sh" without quotes.
" ..
"Lines beginning with # are comments and are not executed.
" ..
"Put your custom mwan3 action here, they will
" ..
"be executed with each netifd hotplug interface event
" ..
"on interfaces for which mwan3 is enabled.
" ..
"
" ..
"There are three main environment variables that are passed to this script.
" ..
"
" ..
"$ACTION Either \"ifup\" or \"ifdown\"
" ..
"$INTERFACE Name of the interface which went up or down (e.g. \"wan\" or \"wwan\")
" ..
"$DEVICE Physical device name which interface went up or down (e.g. \"eth0\" or \"wwan0\")
" ..
"
"))
t = f:option(TextValue, "lines")
t.rmempty = true
t.rows = 20
function t.cfgvalue()
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