Skip to content
Snippets Groups Projects
Commit 1bcd6a21 authored by Bob Mottram's avatar Bob Mottram
Browse files

Mesh peer interfaces configuration

parent 8aae517e
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,8 @@ CURR_USER=$USER
VERSION="1.01"
# mesh networking settings
BATMAN_IPV6=
BRIDGE_BATMAN_IPV6=
PEER_BATMAN_IPV6=
# ssh (from https://stribika.github.io/2015/01/04/secure-secure-shell.html)
SSH_CIPHERS="chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr"
......@@ -83,7 +84,7 @@ function configure_ssh_client {
}
function mesh_batman {
if [ ! $BATMAN_IPV6 ]; then
if [ ! $BRIDGE_BATMAN_IPV6 ]; then
return
fi
sudo apt-get -y install iproute bridge-utils libnetfilter-conntrack3 batctl
......@@ -95,6 +96,29 @@ function mesh_batman {
sudo echo 'batman_adv' >> /etc/modules
fi
# If no address has been given then create a ramdom one
if [ ! $PEER_BATMAN_IPV6 ]; then
hexarray=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )
a=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
b=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
c=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
d=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
PEER_BATMAN_IPV6="$IPV6_NETWORK:$a:$b:$c:$d"
fi
sudo cp /etc/network/interfaces ~/interfaces
if ! grep -q "# Mesh Networking (B.A.T.M.A.N)" ~/interfaces; then
echo '' >> ~/interfaces
echo '# Mesh Networking (B.A.T.M.A.N)' >> ~/interfaces
echo 'iface bat0 inet6 static' >> ~/interfaces
echo ' pre-up modprobe ipv6' >> ~/interfaces
echo " address $PEER_BATMAN_IPV6" >> ~/interfaces
echo ' netmask 64' >> ~/interfaces
sudo mv ~/interfaces /etc/network/interfaces
else
sudo rm ~/interfaces
fi
echo '#!/bin/bash' > /tmp/freedombone_mesh
echo '' > /tmp/freedombone_mesh
echo '# stop network manager to make the mesh network work' >> /tmp/freedombone_mesh
......@@ -109,7 +133,7 @@ function mesh_batman {
echo '' >> /tmp/freedombone_mesh
echo '# add the interface to the ad-hoc network - or create it.' >> /tmp/freedombone_mesh
echo -n "iwconfig wlan0 mode ad-hoc essid mesh ap " >> /tmp/freedombone_mesh
echo "$BATMAN_IPV6 channel 2" >> /tmp/freedombone_mesh
echo "$BRIDGE_BATMAN_IPV6 channel 2" >> /tmp/freedombone_mesh
echo '' >> /tmp/freedombone_mesh
echo -n '# add wlan0 to the batman-adv virtual interface(so it can ' >> /tmp/freedombone_mesh
echo 'communicate with other batman-adv nodes)' >> /tmp/freedombone_mesh
......@@ -127,7 +151,7 @@ function mesh_batman {
function show_help {
echo ''
echo 'freedombone-client --mesh-ip [mesh bridge IPv6 address]'
echo 'freedombone-client --bridge-ip [mesh bridge IPv6 address]'
echo ''
exit 0
}
......@@ -140,9 +164,9 @@ case $key in
-h|--help)
show_help
;;
--mesh-ip)
--bridge-ip)
shift
BATMAN_IPV6="$1"
BRIDGE_BATMAN_IPV6="$1"
;;
*)
# unknown option
......@@ -155,7 +179,7 @@ echo 'Configuring client'
configure_ssh_client
mesh_batman
echo 'Configuration complete'
if [[ $BATMAN_IPV6 ]]; then
if [[ $BRIDGE_BATMAN_IPV6 ]]; then
echo ''
echo 'Type "sudo mesh" to connect to the mesh network'
fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment