From 8fa1e36b3e9a0691aca635ed39488edc88753845 Mon Sep 17 00:00:00 2001 From: Manuel Munz Date: Sat, 5 Oct 2013 18:15:35 +0000 Subject: [PATCH] contrib/freifunk-gwcheck: Only run the check when olsrd_dyngw_plain plugin is enabled and also uses the main routing table --- contrib/package/freifunk-gwcheck/Makefile | 2 +- .../files/usr/sbin/ff_olsr_test_gw.sh | 27 +++++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/contrib/package/freifunk-gwcheck/Makefile b/contrib/package/freifunk-gwcheck/Makefile index c339d13fa..6c2affe74 100644 --- a/contrib/package/freifunk-gwcheck/Makefile +++ b/contrib/package/freifunk-gwcheck/Makefile @@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=freifunk-gwcheck -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) diff --git a/contrib/package/freifunk-gwcheck/files/usr/sbin/ff_olsr_test_gw.sh b/contrib/package/freifunk-gwcheck/files/usr/sbin/ff_olsr_test_gw.sh index 3965ea158..6bba7f0b0 100755 --- a/contrib/package/freifunk-gwcheck/files/usr/sbin/ff_olsr_test_gw.sh +++ b/contrib/package/freifunk-gwcheck/files/usr/sbin/ff_olsr_test_gw.sh @@ -3,17 +3,28 @@ # Licensed under the GNU General Public License (GPL) v3 # This script monitors the local internet gateway +. /lib/functions.sh . /lib/functions/network.sh -# exit if dyngw_plain is not installed or enabled -dgwlib=`uci show olsrd |grep dyn_gw_plain |awk {' FS="."; print $1"."$2 '}` -if [ -n "$dgwlib" ]; then - if [ "$(uci -q get $dgwlib.ignore)" == 1 ]; then - exit 1 +# exit if dyngw_plain is not enabled or RtTable is not (254 or unset) +config_load olsrd + +check_dyngw_plain() +{ + local cfg="$1" + config_get library "$cfg" library + if [ "${library#olsrd_dyn_gw_plain}" != "$library" ]; then + config_get ignore "$cfg" ignore + config_get RtTable "$cfg" RtTable + if [ "$ignore" != "1" ] && [ -z "$RtTable" -o "$RtTable" = "254" ]; then + exit=0 + fi fi -else - exit 1 -fi +} + +exit=1 +config_foreach check_dyngw_plain LoadPlugin +[ "$exit" = "1" ] && exit 1 #Exit if this script is already running pid="$(pidof ff_olsr_test_gw.sh)" -- 2.11.0