luci-app-watchcat: add support for run_script mode

Signed-off-by: John Kohl <jtk.git@bostonpog.org>
This commit is contained in:
John Kohl 2022-06-04 21:16:27 -04:00
parent 20fdd8dd9d
commit ae5677b8c2
2 changed files with 63 additions and 40 deletions

View file

@ -22,18 +22,27 @@ return view.extend({
_('Mode'), _('Mode'),
_("Ping Reboot: Reboot this device if a ping to a specified host fails for a specified duration of time. <br /> \ _("Ping Reboot: Reboot this device if a ping to a specified host fails for a specified duration of time. <br /> \
Periodic Reboot: Reboot this device after a specified interval of time. <br /> \ Periodic Reboot: Reboot this device after a specified interval of time. <br /> \
Restart Interface: Restart a network interface if a ping to a specified host fails for a specified duration of time.")); Restart Interface: Restart a network interface if a ping to a specified host fails for a specified duration of time. <br />\
Run Script: Run a script if a ping to a specified host fails for a specified duration of time. <br />"));
o.value('ping_reboot', _('Ping Reboot')); o.value('ping_reboot', _('Ping Reboot'));
o.value('periodic_reboot', _('Periodic Reboot')); o.value('periodic_reboot', _('Periodic Reboot'));
o.value('restart_iface', _('Restart Interface')); o.value('restart_iface', _('Restart Interface'));
o.value('run_script', _('Run Script'));
o = s.taboption('general', form.Value, 'script',
_('Script to run'),
_(`Script to run when the host has not responded for the specified duration of time. The script is passed the interface name as $1`));
o.datatype = 'file';
o.default = "/etc/watchcat.user.sh";
o.depends({ mode: "run_script" });
o = s.taboption('general', form.Value, 'period', o = s.taboption('general', form.Value, 'period',
_('Period'), _('Period'),
_("In Periodic Reboot mode, it defines how often to reboot. <br /> \ _("In Periodic Reboot mode, it defines how often to reboot. <br /> \
In Ping Reboot mode, it defines the longest period of \ In Ping Reboot mode, it defines the longest period of \
time without a reply from the Host To Check before a reboot is engaged. <br /> \ time without a reply from the Host To Check before a reboot is engaged. <br /> \
In Network Restart mode, it defines the longest period of \ In Network Restart or Run Script mode, it defines the longest period of \
time without a reply from the Host to Check before the interface is restarted. \ time without a reply from the Host to Check before the interface is restarted or the script is run. \
<br /><br />The default unit is seconds, without a suffix, but you can use the \ <br /><br />The default unit is seconds, without a suffix, but you can use the \
suffix <b>m</b> for minutes, <b>h</b> for hours or <b>d</b> \ suffix <b>m</b> for minutes, <b>h</b> for hours or <b>d</b> \
for days. <br /><br />Examples:<ul><li>10 seconds would be: <b>10</b> or <b>10s</b></li><li>5 minutes would be: <b>5m</b></li><li> \ for days. <br /><br />Examples:<ul><li>10 seconds would be: <b>10</b> or <b>10s</b></li><li>5 minutes would be: <b>5m</b></li><li> \
@ -45,12 +54,14 @@ return view.extend({
o.default = '8.8.8.8'; o.default = '8.8.8.8';
o.depends({ mode: "ping_reboot" }); o.depends({ mode: "ping_reboot" });
o.depends({ mode: "restart_iface" }); o.depends({ mode: "restart_iface" });
o.depends({ mode: "run_script" });
o = s.taboption('general', form.ListValue, 'addressfamily', o = s.taboption('general', form.ListValue, 'addressfamily',
_('Address family for pinging the host')); _('Address family for pinging the host'));
o.default = 'any'; o.default = 'any';
o.depends({ mode: 'ping_reboot' }); o.depends({ mode: 'ping_reboot' });
o.depends({ mode: 'restart_iface' }); o.depends({ mode: 'restart_iface' });
o.depends({ mode: "run_script" });
o.value('any'); o.value('any');
o.value('ipv4'); o.value('ipv4');
o.value('ipv6'); o.value('ipv6');
@ -63,6 +74,7 @@ return view.extend({
o.default = '30s'; o.default = '30s';
o.depends({ mode: "ping_reboot" }); o.depends({ mode: "ping_reboot" });
o.depends({ mode: "restart_iface" }); o.depends({ mode: "restart_iface" });
o.depends({ mode: "run_script" });
o = s.taboption('general', form.ListValue, 'pingsize', o = s.taboption('general', form.ListValue, 'pingsize',
_('Ping Packet Size')); _('Ping Packet Size'));
@ -75,6 +87,7 @@ return view.extend({
o.default = 'standard'; o.default = 'standard';
o.depends({ mode: 'ping_reboot' }); o.depends({ mode: 'ping_reboot' });
o.depends({ mode: 'restart_iface' }); o.depends({ mode: 'restart_iface' });
o.depends({ mode: "run_script" });
o = s.taboption('general', form.Value, 'forcedelay', o = s.taboption('general', form.Value, 'forcedelay',
_('Force Reboot Delay'), _('Force Reboot Delay'),
@ -88,9 +101,10 @@ return view.extend({
o = s.taboption('general', widgets.DeviceSelect, 'interface', o = s.taboption('general', widgets.DeviceSelect, 'interface',
_('Interface'), _('Interface'),
_('Interface to monitor and/or restart'), _('Interface to monitor and/or restart'),
_('<i>Applies to Ping Reboot and Restart Interface modes</i> <br /> Specify the interface to monitor and restart if a ping over it fails.')); _('<i>Applies to Ping Reboot, Restart Interface, and Run Script modes</i> <br /> Specify the interface to monitor and react if a ping over it fails.'));
o.depends({ mode: 'ping_reboot' }); o.depends({ mode: 'ping_reboot' });
o.depends({ mode: 'restart_iface' }); o.depends({ mode: 'restart_iface' });
o.depends({ mode: 'run_script' });
o = s.taboption('general', widgets.NetworkSelect, 'mmifacename', o = s.taboption('general', widgets.NetworkSelect, 'mmifacename',
_('Name of ModemManager Interface'), _('Name of ModemManager Interface'),

View file

@ -1,17 +1,17 @@
msgid "" msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8" msgstr "Content-Type: text/plain; charset=UTF-8"
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:91 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:104
msgid "" msgid ""
"<i>Applies to Ping Reboot and Restart Interface modes</i> <br /> Specify the " "<i>Applies to Ping Reboot, Restart Interface, and Run Script modes</i> <br /"
"interface to monitor and restart if a ping over it fails." "> Specify the interface to monitor and react if a ping over it fails."
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:50 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:60
msgid "Address family for pinging the host" msgid "Address family for pinging the host"
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:81 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:94
msgid "" msgid ""
"Applies to Ping Reboot and Periodic Reboot modes</i> <br /> When rebooting " "Applies to Ping Reboot and Periodic Reboot modes</i> <br /> When rebooting "
"the router, the service will trigger a soft reboot. Entering a non-zero " "the router, the service will trigger a soft reboot. Entering a non-zero "
@ -20,22 +20,22 @@ msgid ""
"0 to disable the forced reboot delay." "0 to disable the forced reboot delay."
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:97 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:111
msgid "" msgid ""
"Applies to Ping Reboot and Restart Interface modes</i> <br /> If using " "Applies to Ping Reboot and Restart Interface modes</i> <br /> If using "
"ModemManager, you can have Watchcat restart your ModemManger interface by " "ModemManager, you can have Watchcat restart your ModemManger interface by "
"specifying its name." "specifying its name."
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:72 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:84
msgid "Big: 248 bytes" msgid "Big: 248 bytes"
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:59 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:70
msgid "Check Interval" msgid "Check Interval"
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:80 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:93
msgid "Force Reboot Delay" msgid "Force Reboot Delay"
msgstr "" msgstr ""
@ -54,11 +54,11 @@ msgid ""
"up more than one action." "up more than one action."
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:43 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:52
msgid "Host To Check" msgid "Host To Check"
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:60 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:71
msgid "" msgid ""
"How often to ping the host specified above. <br /><br />The default unit is " "How often to ping the host specified above. <br /><br />The default unit is "
"seconds, without a suffix, but you can use the suffix <b>m</b> for minutes, " "seconds, without a suffix, but you can use the suffix <b>m</b> for minutes, "
@ -68,39 +68,39 @@ msgid ""
"li><ul>" "li><ul>"
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:73 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:85
msgid "Huge: 1492 bytes" msgid "Huge: 1492 bytes"
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:104 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:118
msgid "" msgid ""
"If using ModemManager, then before restarting the interface, set the modem " "If using ModemManager, then before restarting the interface, set the modem "
"to be allowed to use any band." "to be allowed to use any band."
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:32 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:41
msgid "" msgid ""
"In Periodic Reboot mode, it defines how often to reboot. <br /> In Ping " "In Periodic Reboot mode, it defines how often to reboot. <br /> In Ping "
"Reboot mode, it defines the longest period of time without a reply from the " "Reboot mode, it defines the longest period of time without a reply from the "
"Host To Check before a reboot is engaged. <br /> In Network Restart mode, it " "Host To Check before a reboot is engaged. <br /> In Network Restart or Run "
"defines the longest period of time without a reply from the Host to Check " "Script mode, it defines the longest period of time without a reply from the "
"before the interface is restarted. <br /><br />The default unit is seconds, " "Host to Check before the interface is restarted or the script is run. <br /"
"without a suffix, but you can use the suffix <b>m</b> for minutes, <b>h</b> " "><br />The default unit is seconds, without a suffix, but you can use the "
"for hours or <b>d</b> for days. <br /><br />Examples:<ul><li>10 seconds " "suffix <b>m</b> for minutes, <b>h</b> for hours or <b>d</b> for days. <br /"
"would be: <b>10</b> or <b>10s</b></li><li>5 minutes would be: <b>5m</b></" "><br />Examples:<ul><li>10 seconds would be: <b>10</b> or <b>10s</b></"
"li><li> 1 hour would be: <b>1h</b></li><li>1 week would be: <b>7d</b></" "li><li>5 minutes would be: <b>5m</b></li><li> 1 hour would be: <b>1h</b></"
"li><ul>" "li><li>1 week would be: <b>7d</b></li><ul>"
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:89 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:102
msgid "Interface" msgid "Interface"
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:90 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:103
msgid "Interface to monitor and/or restart" msgid "Interface to monitor and/or restart"
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:74 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:86
msgid "Jumbo: 9000 bytes" msgid "Jumbo: 9000 bytes"
msgstr "" msgstr ""
@ -108,23 +108,23 @@ msgstr ""
msgid "Mode" msgid "Mode"
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:96 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:110
msgid "Name of ModemManager Interface" msgid "Name of ModemManager Interface"
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:31 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:40
msgid "Period" msgid "Period"
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:27 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:28
msgid "Periodic Reboot" msgid "Periodic Reboot"
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:68 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:80
msgid "Ping Packet Size" msgid "Ping Packet Size"
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:26 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:27
msgid "Ping Reboot" msgid "Ping Reboot"
msgstr "" msgstr ""
@ -134,18 +134,27 @@ msgid ""
"specified duration of time. <br /> Periodic Reboot: Reboot this device after " "specified duration of time. <br /> Periodic Reboot: Reboot this device after "
"a specified interval of time. <br /> Restart Interface: Restart a network " "a specified interval of time. <br /> Restart Interface: Restart a network "
"interface if a ping to a specified host fails for a specified duration of " "interface if a ping to a specified host fails for a specified duration of "
"time." "time. <br /> Run Script: Run a script if a ping to a specified host fails "
"for a specified duration of time. <br />"
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:28 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:29
msgid "Restart Interface" msgid "Restart Interface"
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:69 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:30
msgid "Run Script"
msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:33
msgid "Script to run"
msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:81
msgid "Small: 1 byte" msgid "Small: 1 byte"
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:71 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:83
msgid "Standard: 56 bytes" msgid "Standard: 56 bytes"
msgstr "" msgstr ""
@ -153,7 +162,7 @@ msgstr ""
msgid "These rules will govern how this device reacts to network events." msgid "These rules will govern how this device reacts to network events."
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:103 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:117
msgid "Unlock Modem Bands" msgid "Unlock Modem Bands"
msgstr "" msgstr ""
@ -163,6 +172,6 @@ msgstr ""
msgid "Watchcat" msgid "Watchcat"
msgstr "" msgstr ""
#: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:70 #: applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js:82
msgid "Windows: 32 bytes" msgid "Windows: 32 bytes"
msgstr "" msgstr ""