diff options
author | danrl <mail@danrl.com> | 2017-02-17 11:22:01 +0100 |
---|---|---|
committer | danrl <mail@danrl.com> | 2017-02-17 11:22:01 +0100 |
commit | a25c71f55697d13c0a12da104bde7fee57d00f2c (patch) | |
tree | 7398b15679d049fc3eb9db06451e6898991fd68e /applications/luci-app-mwan3/root | |
parent | 9726e26a7a2ea6052827472bfbec3c9914abedf8 (diff) |
luci-app-mwan3: initial commit
Moved over here from the packages repository.
Signed-off-by: Dan Luedtke <mail@danrl.com>
Diffstat (limited to 'applications/luci-app-mwan3/root')
-rwxr-xr-x | applications/luci-app-mwan3/root/etc/hotplug.d/iface/16-mwancustombak | 38 | ||||
-rwxr-xr-x | applications/luci-app-mwan3/root/etc/uci-defaults/60_luci-mwan3 | 14 |
2 files changed, 52 insertions, 0 deletions
diff --git a/applications/luci-app-mwan3/root/etc/hotplug.d/iface/16-mwancustombak b/applications/luci-app-mwan3/root/etc/hotplug.d/iface/16-mwancustombak new file mode 100755 index 000000000..6e2875e3d --- /dev/null +++ b/applications/luci-app-mwan3/root/etc/hotplug.d/iface/16-mwancustombak @@ -0,0 +1,38 @@ +#!/bin/sh + +# to enable this script uncomment the case loop at the bottom +# to report mwan status on interface hotplug ifup/ifdown events modify the lines in the send_alert function + +send_alert() +{ + # variable "$1" stores the MWAN status information + # insert your code here to send the contents of "$1" + echo "$1" +} + +gather_event_info() +{ + # create event information message + local EVENT_INFO="Interface [ "$INTERFACE" ($DEVICE) ] on router [ "$(uci -p /var/state get system.@system[0].hostname)" ] has triggered a hotplug [ "$ACTION" ] event on "$(date +"%a %b %d %Y %T %Z")"" + + # get current interface, policy and rule status + local CURRENT_STATUS="$(/usr/sbin/mwan3 status)" + + # get last 50 MWAN systemlog messages + local MWAN_LOG="$(echo -e "Last 50 MWAN systemlog entries. Newest entries sorted at the top:\n$(logread | grep mwan3 | tail -n 50 | sed 'x;1!H;$!d;x')")" + + # pass event info to send_alert function + send_alert "$(echo -e "$EVENT_INFO\n\n$CURRENT_STATUS\n\n$MWAN_LOG")" +} + +#case "$ACTION" in +# ifup) +# gather_event_info +# ;; +# +# ifdown) +# gather_event_info +# ;; +#esac + +exit 0 diff --git a/applications/luci-app-mwan3/root/etc/uci-defaults/60_luci-mwan3 b/applications/luci-app-mwan3/root/etc/uci-defaults/60_luci-mwan3 new file mode 100755 index 000000000..ff9a229ed --- /dev/null +++ b/applications/luci-app-mwan3/root/etc/uci-defaults/60_luci-mwan3 @@ -0,0 +1,14 @@ +#!/bin/sh + +# replace existing mwan ucitrack entry +uci -q batch <<-EOF >/dev/null + del ucitrack.@mwan3[-1] + add ucitrack mwan3 + set ucitrack.@mwan3[-1].exec="/usr/sbin/mwan3 restart" + commit ucitrack +EOF + +# remove LuCI cache +rm -rf /tmp/luci-indexcache /tmp/luci-modulecache + +exit 0 |