Commit 5695dea2 authored by Nico's avatar Nico
Browse files

ffs-set-segment: remove old shell code

parent 114d9c26
......@@ -146,82 +146,3 @@ if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
main()
"""
set -eu
set -o pipefail
NODEID=$(uci get network.bat-1.macaddr | sed 's/://g')
PUBKEY=$(/etc/init.d/fastd show_key mesh_vpn | cut -c1-12)
DNSDOM="freifunk-stuttgart.de"
DNSREQ="ffs-${NODEID}-${PUBKEY}.segassign.${DNSDOM}"
DNSLIST="::1#54 $(cat /var/gluon/wan-dnsmasq/resolv.conf | cut -d ' ' -f2)"
for ip in $DNSLIST;
do
if [ "$(echo ${ip} | cut -d':' -f1)" = "fe80" ]; then
DNSSRV=${ip}%br-wan
else
DNSSRV=${ip}
fi
logger -t $ME "DNSv6 on ${DNSSRV} for ${DNSREQ} ..."
GITSEG=$(nslookup ${DNSREQ} ${DNSSRV} | grep "2001:2:0:711::" | cut -d':' -f7)
if [ -z "$GITSEG" ]; then
logger -t $ME "DNSv4 on ${DNSSRV} for ${DNSREQ} ..."
GITSEG=$(nslookup ${DNSREQ} ::1#54 | grep "198.18.190." | cut -d'.' -f4)
fi
if [ -n "$GITSEG" ]; then
break
fi
done
if [ -z "$GITSEG" ]; then
DNSERR=$(nslookup ${DNSREQ} ::1#54 2>&1)
logger -t $ME "DNS not working: $DNSERR"
logger -t $ME "DNS settings: $(cat /var/gluon/wan-dnsmasq/resolv.conf)"
exit 1
else
if [ "$DNSSRV" != "::1#54" ]; then
logger -t $ME "DNSMASQ not working - will be restarted"
/etc/init.d/gluon-wan-dnsmasq stop
/etc/init.d/gluon-wan-dnsmasq start
fi
fi
if [ -n "$BATSEG" ] && [ "$BATSEG" != "$GITSEG" ]; then
logger -t $ME "Avoiding Shortcut: $BATSEG - $GITSEG"
GITSEG=99
else
if [ "$GITSEG" = "99" ]; then
logger -t $ME "Node not registered"
else
logger -t $ME "Node is in Segment $GITSEG"
fi
fi
let PORT=GITSEG+10200
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=$(printf "\"gw%02ds%02d.gw.${DNSDOM}\" port %d" $i $GITSEG $PORT)
if [ "$NEWPEER" != "$OLDPEER" ]; then
uci set fastd.mesh_vpn_backbone_peer_${GW}.remote="$NEWPEER"
CHANGED=1
fi
done
if [ "$CHANGED" = "1" ]; then
/sbin/ifdown client
/etc/init.d/fastd restart
/sbin/ifup client
logger -t $ME "Set Segment: $GITSEG"
else
logger -t $ME "No changes"
fi
"""
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