summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoregon0 <ms@resonar.de>2011-06-20 05:48:48 (GMT)
committeregon0 <ms@resonar.de>2011-06-20 05:48:48 (GMT)
commitd637bf7c57ecceb852c61a5727b2185a50e87a5b (patch)
tree615ed75a08acf9b368e0617a8287d5c49b163470
parente9609c3e14a9dc20f5e3e112bc9897cc1b22939f (diff)
* first implementation of n2n watchdog
-rwxr-xr-xfiles/sbin/n2n_watchdog24
1 files changed, 24 insertions, 0 deletions
diff --git a/files/sbin/n2n_watchdog b/files/sbin/n2n_watchdog
new file mode 100755
index 0000000..aeedcb7
--- /dev/null
+++ b/files/sbin/n2n_watchdog
@@ -0,0 +1,24 @@
+#!/bin/ash
+
+if [[ `uci get batman-adv.bat0.gw_mode` = "server" ]]; then
+
+ n2n_pwd=`wget http://www.freifunk-jena.de/n2n -O - -q`
+ n2n1_pwd_old=`uci get n2n.@edge[1].key`
+ n2n2_pwd_old=`uci get n2n.@edge[0].key`
+
+ if [[ $n2n_pwd != $n2n1_pwd_old && $n2n_pwd != "" -o $n2n_pwd != $n2n2_pwd_old && $n2n_pwd != "" ]]; then
+ uci set n2n.@edge[0].key=$n2n_pwd
+ uci set n2n.@edge[1].key=$n2n_pwd
+ uci commit n2n
+ /etc/init.d/n2n restart
+ fi
+
+ sleep 5
+ n2n_neighbors=`batctl o | grep n2n | wc -l`
+
+ if [[ $n2n_neighbors -lt 1 ]]; then
+ /etc/init.d/n2n restart
+ fi
+else
+ exit 0
+fi
contact: Jan Huwald // Impressum