Commit 414ba45e authored by ffs-Monitor's avatar ffs-Monitor

optimized script an make it more robust.

parent 647d77b9
#!/bin/sh
ME=$(basename $0)
if [ $(ps | grep -c "{$(basename $0)}") -gt 4 ]; then
if [ $(ps | grep -c "$ME") -gt 4 ]; then
logger -s -t $ME "started twice"
exit 1
fi
......@@ -15,7 +15,7 @@ fi
NODEID=$(uci get network.bat0.macaddr | sed 's/://g')
PUBKEY=$(/etc/init.d/fastd show_key mesh_vpn | cut -c1-12)
SEGINFO=$(nslookup ffs-$NODEID-$PUBKEY.segassign.freifunk-stuttgart.de [::1]:54 | grep "2001:2:0:711::")
SEGINFO=$(nslookup ffs-${NODEID}-${PUBKEY}.segassign.freifunk-stuttgart.de [::1]:54 | grep "2001:2:0:711::")
if [ -z "$SEGINFO" ]; then
logger -t $ME "Node not known"
exit 1
......@@ -33,11 +33,11 @@ CHANGED=0
for i in `seq 1 10`;
do
GW=$(printf "gw%02d" $i)
OLDPEER=$(uci get fastd.mesh_vpn_backbone_peer_$GW.remote)
NEWPEER="\"${GW}s$SEGNUM.gw.freifunk-stuttgart.de\" port $PORT"
OLDPEER=$(uci get fastd.mesh_vpn_backbone_peer_${GW}.remote)
NEWPEER="\"${GW}s${SEGNUM}.gw.freifunk-stuttgart.de\" port $PORT"
if [ "$NEWPEER" != "$OLDPEER" ]; then
uci set fastd.mesh_vpn_backbone_peer_$GW.remote="$NEWPEER"
uci set fastd.mesh_vpn_backbone_peer_${GW}.remote="$NEWPEER"
CHANGED=1
fi
done
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment