summaryrefslogtreecommitdiffhomepage
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/package/freifunk-gwcheck/files/usr/sbin/ff_olsr_test_gw.sh18
-rw-r--r--contrib/package/freifunk-gwcheck/root/etc/uci-defaults/freifunk-gwcheck1
2 files changed, 10 insertions, 9 deletions
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 5d34d9a55..a622a4fc4 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,7 +3,7 @@
#check if dyngw_plain is installed and enabled, else exit
dyngwplainlib=`uci show olsrd |grep dyn_gw_plain |awk {' FS="."; print $1"."$2 '}`
if [ -n "$dyngwplainlib" ]; then
- if [ ! "$(uci -q get $dyngwplainlib.ignore)" == 0 ]; then
+ if [ "$(uci -q get $dyngwplainlib.ignore)" == 1 ]; then
exit 1
fi
else
@@ -15,14 +15,14 @@ fi
# check if we have a defaultroute with metric=0 in one of these tables: main table and gw-check table.
# If not exit here.
defroutemain="$(ip r s |grep default |grep -v metric)"
-defroutegw-check="$(ip r s t gw-check |grep default |grep -v metric)"
-if [ -z "$defroutegw-check" -a -z "$defroutemain" ]; then
+defroutegwcheck="$(ip r s t gw-check |grep default |grep -v metric)"
+if [ -z "$defroutegwcheck" -a -z "$defroutemain" ]; then
exit 1
fi
# get and shuffle list of testservers
testserver="$(uci -q get freifunk-gwcheck.hosts.host)"
-[ -z "$testserver" ] && echo "No testservers found, exit" && exit
+[ -z "$testserver" ] && echo "No testservers found, exit" && exit
testserver="$(for t in $testserver; do echo $t; done | awk 'BEGIN {
srand();
@@ -57,16 +57,16 @@ iw=$(check_internet)
if [ "$iw" == 0 ]; then
# check if we have a seperate routing table for our tests.
# If yes, move defaultroute to normal table and delete table gw-check
- if [ -n "$defroutegw-check" ]; then
- ip r a $defroutegw-check
- ip r d $defroutegw-check t gw-check
+ if [ -n "$defroutegwcheck" ]; then
+ ip r a $defroutegwcheck
+ ip r d $defroutegwcheck t gw-check
ip ru del fwmark 0x2 lookup gw-check
for host in $testserver; do
iptables -t mangle -D OUTPUT -d $host -p tcp --dport 80 -j MARK --set-mark 0x2
done
- logger -t gw-check "Internet is available again, restoring default route ( $defroutegw-check)"
+ logger -t gw-check "Internet is available again, restoring default route ( $defroutegwcheck)"
fi
-
+
else
# Check failed. If we have a defaultroute with metric=0 and it is already in table gw-check then do nothing.
# If there is a defaultroute with metric=0 then remove it from the main routing table and add to table gw-check.
diff --git a/contrib/package/freifunk-gwcheck/root/etc/uci-defaults/freifunk-gwcheck b/contrib/package/freifunk-gwcheck/root/etc/uci-defaults/freifunk-gwcheck
index e04faa562..33b1b99df 100644
--- a/contrib/package/freifunk-gwcheck/root/etc/uci-defaults/freifunk-gwcheck
+++ b/contrib/package/freifunk-gwcheck/root/etc/uci-defaults/freifunk-gwcheck
@@ -1,5 +1,6 @@
#!/bin/sh
tables="/etc/iproute2/rt_tables"
+test -d /etc/iproute2/ || mkdir -p /etc/iproute2/
grep -q "gw-check" $tables || echo "200 gw-check" >> $tables
test -f /etc/crontabs/root || touch /etc/crontabs/root
grep -q "ff_olsr_test_gw.sh" /etc/crontabs/root || echo "* * * * * /usr/sbin/ff_olsr_test_gw.sh" >> /etc/crontabs/root