From ae5677b8c24b7be5cbca5dbef00178b88a1161ac Mon Sep 17 00:00:00 2001 From: John Kohl Date: Sat, 4 Jun 2022 21:16:27 -0400 Subject: [PATCH] luci-app-watchcat: add support for run_script mode Signed-off-by: John Kohl --- .../luci-static/resources/view/watchcat.js | 22 ++++- .../po/templates/watchcat.pot | 81 ++++++++++--------- 2 files changed, 63 insertions(+), 40 deletions(-) diff --git a/applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js b/applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js index 670dfcde32..dc9e0084bc 100644 --- a/applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js +++ b/applications/luci-app-watchcat/htdocs/luci-static/resources/view/watchcat.js @@ -22,18 +22,27 @@ return view.extend({ _('Mode'), _("Ping Reboot: Reboot this device if a ping to a specified host fails for a specified duration of time.
\ Periodic Reboot: Reboot this device after a specified interval of time.
\ - 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.
\ + Run Script: Run a script if a ping to a specified host fails for a specified duration of time.
")); o.value('ping_reboot', _('Ping Reboot')); o.value('periodic_reboot', _('Periodic Reboot')); 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', _('Period'), _("In Periodic Reboot mode, it defines how often to reboot.
\ In Ping Reboot mode, it defines the longest period of \ time without a reply from the Host To Check before a reboot is engaged.
\ - In Network Restart mode, it defines the longest period of \ - time without a reply from the Host to Check before the interface is restarted. \ + 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 or the script is run. \

The default unit is seconds, without a suffix, but you can use the \ suffix m for minutes, h for hours or d \ for days.

Examples: