From 5a33f6bd787866110c2be3e409620c12c9cca821 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 6 Jun 2012 01:58:31 +0200 Subject: [PATCH] Detect own gateway state --- mkmap.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mkmap.sh b/mkmap.sh index a9a0292..e0f00cc 100755 --- a/mkmap.sh +++ b/mkmap.sh @@ -3,10 +3,17 @@ DEST=$1 -GWS=`(/usr/sbin/batctl gwl -n | tail -n +2 | grep -v '^No' | sed 's/=>//' | awk '{ print $1 }') | while read a; do echo -n "-g $a "; done` +GWL=`batctl gwl -n` -/usr/sbin/batctl vd json | "$(dirname "$0")"/bat2nodes.py -a "$(dirname "$0")"/aliases.json $GWS - > $DEST/nodes.json.new -/usr/sbin/batctl vd json | "$(dirname "$0")"/bat2geomap.py -a "$(dirname "$0")"/aliases.json - > $DEST/geomap.kml.new +SELF=`echo "$GWL" | head -n 1 | sed -r -e 's@^.*MainIF/MAC: [^/]+/([0-9a-f:]+).*$@\1@'` +GWS=`(echo "$GWL" | tail -n +2 | grep -v '^No' | sed 's/=>//' | awk '{ print $1 }') | while read a; do echo -n "-g $a "; done` + +if [ `cat /sys/class/net/bat0/mesh/gw_mode` = server ]; then + GWS="$GWS -g $SELF" +fi + +batctl vd json | "$(dirname "$0")"/bat2nodes.py -a "$(dirname "$0")"/aliases.json $GWS - > $DEST/nodes.json.new +batctl vd json | "$(dirname "$0")"/bat2geomap.py -a "$(dirname "$0")"/aliases.json - > $DEST/geomap.kml.new mv $DEST/nodes.json.new $DEST/nodes.json mv $DEST/geomap.kml.new $DEST/geomap.kml