luci-app-mwan3: move/rename hotplugscript tab
[project/luci.git] / applications / luci-app-mwan3 / luasrc / model / cbi / mwan / notify.lua
1 -- ------ hotplug script configuration ------ --
2
3 fs = require "nixio.fs"
4 ut = require "luci.util"
5
6 script = "/etc/mwan3.user"
7
8 m5 = SimpleForm("luci", nil)
9
10 f = m5:section(SimpleSection, nil,
11         translate("This section allows you to modify the content of \"/etc/mwan3.user\".<br />" ..
12         "The file is also preserved during sysupgrade.<br />" ..
13         "<br />" ..
14         "Notes:<br />" ..
15         "This file is interpreted as a shell script.<br />" ..
16         "The first line of the script must be &#34;#!/bin/sh&#34; without quotes.<br />" ..
17         "Lines beginning with # are comments and are not executed.<br />" ..
18         "Put your custom mwan3 action here, they will<br />" ..
19         "be executed with each netifd hotplug interface event<br />" ..
20         "on interfaces for which mwan3 is enabled.<br />" ..
21         "<br />" ..
22         "There are three main environment variables that are passed to this script.<br />" ..
23         "<br />" ..
24         "$ACTION Either \"ifup\" or \"ifdown\"<br />" ..
25         "$INTERFACE Name of the interface which went up or down (e.g. \"wan\" or \"wwan\")<br />" ..
26         "$DEVICE Physical device name which interface went up or down (e.g. \"eth0\" or \"wwan0\")<br />" ..
27         "<br />"))
28
29 t = f:option(TextValue, "lines")
30         t.rmempty = true
31         t.rows = 20
32         function t.cfgvalue()
33                 return fs.readfile(script)
34         end
35         function t.write(self, section, data) -- format and write new data to script
36                 return fs.writefile(script, ut.trim(data:gsub("\r\n", "\n")) .. "\n")
37         end
38
39 return m5