Simplified batman
This commit is contained in:
parent
446d3fca7c
commit
462d418a1b
|
@ -1533,6 +1533,9 @@ function get_batman_ipv6_address {
|
||||||
function mesh_batman {
|
function mesh_batman {
|
||||||
# https://sudoroom.org/wiki/Mesh/Relay_setup
|
# https://sudoroom.org/wiki/Mesh/Relay_setup
|
||||||
# also see http://www.netlore.co.uk/airmesh/
|
# also see http://www.netlore.co.uk/airmesh/
|
||||||
|
# https://www.youtube.com/watch?v=CLKHWfQlFqQ
|
||||||
|
# http://pastebin.com/4U9vdFFm
|
||||||
|
# http://pastebin.com/eeTmL5XL
|
||||||
if grep -Fxq "mesh_batman" $COMPLETION_FILE; then
|
if grep -Fxq "mesh_batman" $COMPLETION_FILE; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
@ -1546,24 +1549,6 @@ function mesh_batman {
|
||||||
echo 'batman_adv' >> /etc/modules
|
echo 'batman_adv' >> /etc/modules
|
||||||
fi
|
fi
|
||||||
|
|
||||||
modprobe l2tp_core
|
|
||||||
[ $? -ne 0 ] && echo "l2tp_core module not available" && exit 7358
|
|
||||||
if ! grep -q "l2tp_core" /etc/modules; then
|
|
||||||
echo 'l2tp_core' >> /etc/modules
|
|
||||||
fi
|
|
||||||
|
|
||||||
modprobe l2tp_eth
|
|
||||||
[ $? -ne 0 ] && echo "l2tp_eth module not available" && exit 8735
|
|
||||||
if ! grep -q "l2tp_eth" /etc/modules; then
|
|
||||||
echo 'l2tp_eth' >> /etc/modules
|
|
||||||
fi
|
|
||||||
|
|
||||||
modprobe l2tp_netlink
|
|
||||||
[ $? -ne 0 ] && echo "l2tp_netlink module not available" && exit 87367
|
|
||||||
if ! grep -q "l2tp_netlink" /etc/modules; then
|
|
||||||
echo 'l2tp_netlink' >> /etc/modules
|
|
||||||
fi
|
|
||||||
|
|
||||||
enable_ipv6
|
enable_ipv6
|
||||||
get_batman_ipv6_address
|
get_batman_ipv6_address
|
||||||
|
|
||||||
|
@ -1591,48 +1576,35 @@ function mesh_batman {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# TODO add wlan0
|
||||||
|
|
||||||
apt-get -y install iproute bridge-utils libnetfilter-conntrack3 python-dev libevent-dev ebtables python-pip git
|
apt-get -y install iproute bridge-utils libnetfilter-conntrack3 python-dev libevent-dev ebtables python-pip git
|
||||||
|
|
||||||
cd $BUILD_PATH
|
# TODO turn the following into a script which can be run on startup
|
||||||
git clone https://github.com/wlanslovenija/tunneldigger.git /opt/tunneldigger
|
|
||||||
chown root:root -R /opt/tunneldigger
|
|
||||||
cd /opt/tunneldigger/broker
|
|
||||||
pip install -r requirements.txt
|
|
||||||
|
|
||||||
sed -i 's|address=.*|address=$BATMAN_IPV6|g' l2tp_broker.cfg
|
# stop network manager to make the mesh network work
|
||||||
sed -i 's|interface=.*|interface=eth0|g' l2tp_broker.cfg
|
service networking stop
|
||||||
sed -i 's|session.up=.*|session.up=/opt/tunneldigger/broker/scripts/up_hook.sh|g' l2tp_broker.cfg
|
|
||||||
|
|
||||||
cd /opt/tunneldigger/broker/scripts
|
# configure the wlan interface to operate with mtus of 1532(batman requires it) and turn enc off to ensure it works
|
||||||
echo '#!/bin/sh' > /opt/tunneldigger/broker/scripts/up_hook.sh
|
ifconfig wlan0 down
|
||||||
echo 'INTERFACE="$3"' >> /opt/tunneldigger/broker/scripts/up_hook.sh
|
ifconfig wlan0 mtu 1532
|
||||||
echo 'ifconfig $INTERFACE up' >> /opt/tunneldigger/broker/scripts/up_hook.sh
|
iwconfig wlan0 enc off
|
||||||
echo 'batctl if add $INTERFACE' >> /opt/tunneldigger/broker/scripts/up_hook.sh
|
|
||||||
echo 'if [ `cat /sys/class/net/bat0/operstate` != "up" ]; then' >> /opt/tunneldigger/broker/scripts/up_hook.sh
|
|
||||||
echo " ifconfig bat0 up" >> /opt/tunneldigger/broker/scripts/up_hook.sh
|
|
||||||
echo 'fi' >> /opt/tunneldigger/broker/scripts/up_hook.sh
|
|
||||||
chmod 755 up_hook.sh
|
|
||||||
|
|
||||||
# make a systemd service to run ./l2tp_broker.py l2tp_broker.cfg
|
# add the interface to the ad-hoc network - or create it.
|
||||||
echo '[Unit]' > /etc/systemd/system/tunneldigger.service
|
iwconfig wlan0 mode ad-hoc essid NetworkName ap $BATMAN_IPV6 channel 2
|
||||||
echo 'Description=tunnerdigger (l2tp tunnel)' >> /etc/systemd/system/tunneldigger.service
|
|
||||||
echo 'After=syslog.target' >> /etc/systemd/system/tunneldigger.service
|
# add wlan0 to the batman-adv virtual interface(so it can communicate with other batman-adv nodes)
|
||||||
echo 'After=network.target' >> /etc/systemd/system/tunneldigger.service
|
batctl if add wlan0
|
||||||
echo '' >> /etc/systemd/system/tunneldigger.service
|
ifconfig wlan0 up
|
||||||
echo '[Service]' >> /etc/systemd/system/tunneldigger.service
|
ifconfig bat0 up
|
||||||
echo 'Type=simple' >> /etc/systemd/system/tunneldigger.service
|
|
||||||
echo 'User=root' >> /etc/systemd/system/tunneldigger.service
|
# make the bridge linking the batman-adv virtual interface to the ethernet port
|
||||||
echo 'Group=root' >> /etc/systemd/system/tunneldigger.service
|
brctl addbr bridge-link
|
||||||
echo 'WorkingDirectory=/opt/tunneldigger/broker' >> /etc/systemd/system/tunneldigger.service
|
brctl addif bridge-link bat0
|
||||||
echo 'ExecStart=/opt/tunneldigger/broker/l2tp_broker.py l2tp_broker.cfg' >> /etc/systemd/system/tunneldigger.service
|
brctl addif bridge-link eth0
|
||||||
echo 'Restart=always' >> /etc/systemd/system/tunneldigger.service
|
|
||||||
echo 'Environment="USER=root" "HOME=/opt/tunneldigger/broker"' >> /etc/systemd/system/tunneldigger.service
|
#get the ip address for the bridge from the dhcp server
|
||||||
echo '' >> /etc/systemd/system/tunneldigger.service
|
dhclient bridge-link
|
||||||
echo '[Install]' >> /etc/systemd/system/tunneldigger.service
|
|
||||||
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/tunneldigger.service
|
|
||||||
systemctl enable tunneldigger
|
|
||||||
systemctl daemon-reload
|
|
||||||
systemctl restart tunneldigger
|
|
||||||
|
|
||||||
if ! grep -q "Mesh Networking (B.A.T.M.A.N)" /home/$MY_USERNAME/README; then
|
if ! grep -q "Mesh Networking (B.A.T.M.A.N)" /home/$MY_USERNAME/README; then
|
||||||
echo '' >> /home/$MY_USERNAME/README
|
echo '' >> /home/$MY_USERNAME/README
|
||||||
|
|
Loading…
Reference in New Issue