ansible.fftdf.supernode/files/gre_backbone.sh.j2

58 lines
2.1 KiB
Plaintext
Raw Normal View History

2015-11-28 14:25:29 +00:00
#!/bin/sh
# Server name ending must be a single digit number
communityname="troisdorf"
2015-12-14 19:07:50 +00:00
server="troisdorf0 {{ sn_hostname }}"
2015-11-28 14:25:29 +00:00
domain="freifunk-troisdorf.de"
2015-12-22 19:30:16 +00:00
mtu={{ sn_mtu }}
2015-11-28 14:25:29 +00:00
# community MAC address, without the last Byte (:)!
communitymacaddress="a2:8c:ae:6f:f6"
# Network part of the network, without the trailing dot
communitynetwork="10.188"
# IPv6 network
communitynetworkv6="fda0:747e:ab29:7405:255::"
# Third octet from the server range
octet3rd="255"
# CIDR muss /16 sein
localserver=$(/bin/hostname)
2015-12-13 12:33:33 +00:00
# files
batadv=/usr/local/sbin/batadv-vis
alfred=/usr/local/sbin/alfred
batctl=/usr/local/sbin/batctl
2015-11-28 14:25:29 +00:00
for i in $server; do
(
for j in $server; do
if [ $i != $j ]; then
if [ $i = $(/bin/hostname) ]; then
2015-12-17 10:21:59 +00:00
/sbin/ip link add $j type gretap local $(/bin/hostname -I | /usr/bin/cut -f1 -d' ') remote $(/usr/bin/dig +short $j.$domain) dev eth0 nopmtudisc
# /sbin/ip link add $j type gretap local $(/bin/hostname -I | /usr/bin/cut -f1 -d' ') remote $(/usr/bin/dig +short $j.$domain) dev eth0
/sbin/ip link set dev $j mtu $mtu
2015-12-14 19:07:50 +00:00
# /sbin/ip link set address $communitymacaddress:${i#$communityname}${j#$communityname} dev $j
# /sbin/ip link set address $communitymacaddress$:0${localserver#$communityname} dev $j
/sbin/ip link set address $communitymacaddress$:${localserver#$communityname}0 dev $j
/sbin/ip link set $j up
2015-12-13 12:33:33 +00:00
$batctl if add $j
2015-11-28 14:25:29 +00:00
fi
fi
done
)
done
# configure bat0
/sbin/ip link set address $communitymacaddress$:0${localserver#$communityname} dev bat0
/sbin/ip link set up dev bat0
/sbin/ip addr add $communitynetwork.$octet3rd.${localserver#$communityname}/16 broadcast $communitynetwork.255.255 dev bat0
/sbin/ip -6 addr add fda0:747e:ab29:7405:255::${localserver#$communityname}/64 dev bat0
2015-12-13 12:33:33 +00:00
/usr/bin/killall alfred
/usr/bin/killall batadv-vis
/bin/sleep 5
$alfred -i bat0 > /dev/null 2>&1 &
/bin/sleep 15
$batadv -i bat0 -s > /dev/null 2>&1 &
/usr/sbin/service bind9 restart