-- Copyright 2014 Aedan Renner -- Copyright 2018 Florian Eckert -- Licensed to the public under the GNU General Public License v2. local fs = require "nixio.fs" local ut = require "luci.util" local script = "/etc/mwan3.user" local m, f, t m = SimpleForm("luci", translate("MWAN - Notification")) f = m: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
" .. "* \"ifup\" Is called by netifd and mwan3track
" .. "* \"ifdown\" Is called by netifd and mwan3track
" .. "* \"connected\" Is only called by mwan3track if tracking was successful
" .. "* \"disconnected\" Is only called by mwan3track if tracking has failed
" .. "$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) return fs.writefile(script, ut.trim(data:gsub("\r\n", "\n")) .. "\n") end return m