From 65a9d5e055a7b15751929f708b0945395fcea3b6 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Tue, 26 May 2020 07:57:36 +0200 Subject: [PATCH] Allow to exec a script when interface up or down --- mptcp/files/usr/share/omr/post-tracking.d/post-tracking | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mptcp/files/usr/share/omr/post-tracking.d/post-tracking b/mptcp/files/usr/share/omr/post-tracking.d/post-tracking index 796975058..317b94836 100755 --- a/mptcp/files/usr/share/omr/post-tracking.d/post-tracking +++ b/mptcp/files/usr/share/omr/post-tracking.d/post-tracking @@ -280,6 +280,8 @@ if [ "$OMR_TRACKER_STATUS" = "ERROR" ]; then echo -e "Subject: $OMR_SYSNAME: $OMR_TRACKER_INTERFACE ($OMR_TRACKER_DEVICE) is down\n\nConnection failure of $OMR_TRACKER_INTERFACE ($OMR_TRACKER_DEVICE) detected. The reason is \"$OMR_TRACKER_STATUS_MSG\"." | sendmail $(uci -q get mail.default.to) fi } + script_alert_down="$(uci -q get omr-tracker.$OMR_TRACKER_INTERFACE.script_alert_down)" + [ -n "$script_alert_down" ] && eval $script_alert_down if [ "$OMR_TRACKER_INTERFACE" = "glorytun" ] || [ "$OMR_TRACKER_INTERFACE" = "omrvpn" ]; then if [ "$OMR_TRACKER_STATUS_MSG" = "" ]; then @@ -391,6 +393,9 @@ if [ "$OMR_TRACKER_PREV_STATUS" != "" ] && [ "$OMR_TRACKER_PREV_STATUS" != "$OMR OMR_SYSNAME="$(uci -q get system.@system[0].hostname)" echo -e "Subject: $OMR_SYSNAME: $OMR_TRACKER_INTERFACE ($OMR_TRACKER_DEVICE) is up\n\nDetected that connection $OMR_TRACKER_INTERFACE ($OMR_TRACKER_DEVICE) is up again." | sendmail $(uci -q get mail.default.to) } + script_alert_up="$(uci -q get omr-tracker.$OMR_TRACKER_INTERFACE.script_alert_up)" + [ -n "$script_alert_up" ] && eval $script_alert_up + uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.state='up' uci -q commit openmptcprouter dns_flush