1 -- Copyright 2014 Aedan Renner <chipdankly@gmail.com>
2 -- Copyright 2018 Florian Eckert <fe@dev.tdt.de>
3 -- Licensed to the public under the GNU General Public License v2.
5 local fs = require "nixio.fs"
6 local ut = require "luci.util"
7 script = "/etc/mwan3.user"
10 m5 = SimpleForm("luci", translate("MWAN - Notification"))
12 f = m5:section(SimpleSection, nil,
13 translate("This section allows you to modify the content of \"/etc/mwan3.user\".<br />" ..
14 "The file is also preserved during sysupgrade.<br />" ..
17 "This file is interpreted as a shell script.<br />" ..
18 "The first line of the script must be "#!/bin/sh" without quotes.<br />" ..
19 "Lines beginning with # are comments and are not executed.<br />" ..
20 "Put your custom mwan3 action here, they will<br />" ..
21 "be executed with each netifd hotplug interface event<br />" ..
22 "on interfaces for which mwan3 is enabled.<br />" ..
24 "There are three main environment variables that are passed to this script.<br />" ..
27 "* \"ifup\" Is called by netifd and mwan3track <br />" ..
28 "* \"ifdown\" Is called by netifd and mwan3track <br />" ..
29 "* \"connected\" Is only called by mwan3track if tracking was successful <br />" ..
30 "* \"disconnected\" Is only called by mwan3track if tracking has failed <br />" ..
31 "$INTERFACE Name of the interface which went up or down (e.g. \"wan\" or \"wwan\")<br />" ..
32 "$DEVICE Physical device name which interface went up or down (e.g. \"eth0\" or \"wwan0\")<br />" ..
35 t = f:option(TextValue, "lines")
39 return fs.readfile(script)
41 function t.write(self, section, data)
42 return fs.writefile(script, ut.trim(data:gsub("\r\n", "\n")) .. "\n")