From dc022f9e55dd5df039997363436bbddd433b479e Mon Sep 17 00:00:00 2001 From: Vasil Kolev Date: Tue, 29 Oct 2019 15:47:41 +0200 Subject: [PATCH] wifi-sentinel: make the switchport configurable, as it differs --- files/all/usr/bin/wifi-sentinel.sh | 35 ++++++++++++++++--- .../etc/config/wifi-sentinel | 1 + files/dap2965/etc/config/wifi-sentinel | 6 ++++ files/linksys/etc/config/wifi-sentinel | 6 ++++ files/wdr-4300/etc/config/wifi-sentinel | 6 ++++ files/wr-1043nd/etc/config/wifi-sentinel | 6 ++++ 6 files changed, 55 insertions(+), 5 deletions(-) rename files/{all => archer-c5}/etc/config/wifi-sentinel (79%) create mode 100644 files/dap2965/etc/config/wifi-sentinel create mode 100644 files/linksys/etc/config/wifi-sentinel create mode 100644 files/wdr-4300/etc/config/wifi-sentinel create mode 100644 files/wr-1043nd/etc/config/wifi-sentinel diff --git a/files/all/usr/bin/wifi-sentinel.sh b/files/all/usr/bin/wifi-sentinel.sh index 88beb2b..2294736 100755 --- a/files/all/usr/bin/wifi-sentinel.sh +++ b/files/all/usr/bin/wifi-sentinel.sh @@ -1,11 +1,36 @@ #!/bin/sh . /lib/functions/network.sh -PACKETS='3' -INTERVAL='10' +p=$(uci get wifi-sentinel.@wifi-sentinel[0].packets) +if [ -z "$p" ]; then + PACKETS='3' +else + PACKETS="$p" +fi + +p=$(uci get wifi-sentinel.@wifi-sentinel[0].interval) +if [ -z "$p" ]; then + INTERVAL='10' +else + INTERVAL="$p" +fi + +p=$(uci get wifi-sentinel.@wifi-sentinel[0].network) +if [ -z "$p" ]; then + NETWORK='management' +else + NETWORK="$p" +fi + +p=$(uci get wifi-sentinel.@wifi-sentinel[0].switchport) +if [ -z "$p" ]; then + PORT=1 +else + PORT="$p" +fi + + STATUS='unknown' -NETWORK='management' -PORT='1' lightsoff() { @@ -27,7 +52,7 @@ lightson() port_check() { - LINK=`swconfig dev switch0 port 1 show | awk '/link/ {print $3}'` + LINK=`swconfig dev switch0 port $PORT show | awk '/link/ {print $3}'` if [ "$LINK" = 'link:up' ]; then return 0 else diff --git a/files/all/etc/config/wifi-sentinel b/files/archer-c5/etc/config/wifi-sentinel similarity index 79% rename from files/all/etc/config/wifi-sentinel rename to files/archer-c5/etc/config/wifi-sentinel index 61e22f5..92d9030 100644 --- a/files/all/etc/config/wifi-sentinel +++ b/files/archer-c5/etc/config/wifi-sentinel @@ -3,3 +3,4 @@ config wifi-sentinel option packets 3 option interval 10 option network 'management' + option switchport '1' diff --git a/files/dap2965/etc/config/wifi-sentinel b/files/dap2965/etc/config/wifi-sentinel new file mode 100644 index 0000000..9b29910 --- /dev/null +++ b/files/dap2965/etc/config/wifi-sentinel @@ -0,0 +1,6 @@ + +config wifi-sentinel + option packets 3 + option interval 10 + option network 'management' + option switchport '2' diff --git a/files/linksys/etc/config/wifi-sentinel b/files/linksys/etc/config/wifi-sentinel new file mode 100644 index 0000000..92d9030 --- /dev/null +++ b/files/linksys/etc/config/wifi-sentinel @@ -0,0 +1,6 @@ + +config wifi-sentinel + option packets 3 + option interval 10 + option network 'management' + option switchport '1' diff --git a/files/wdr-4300/etc/config/wifi-sentinel b/files/wdr-4300/etc/config/wifi-sentinel new file mode 100644 index 0000000..92d9030 --- /dev/null +++ b/files/wdr-4300/etc/config/wifi-sentinel @@ -0,0 +1,6 @@ + +config wifi-sentinel + option packets 3 + option interval 10 + option network 'management' + option switchport '1' diff --git a/files/wr-1043nd/etc/config/wifi-sentinel b/files/wr-1043nd/etc/config/wifi-sentinel new file mode 100644 index 0000000..92d9030 --- /dev/null +++ b/files/wr-1043nd/etc/config/wifi-sentinel @@ -0,0 +1,6 @@ + +config wifi-sentinel + option packets 3 + option interval 10 + option network 'management' + option switchport '1'