Connect peers to the mesh network with the client setup script
This commit is contained in:
parent
ac86ece253
commit
f5c0c908eb
|
@ -377,7 +377,6 @@ CJDNS_PORT=
|
||||||
# B.A.T.M.A.N settings
|
# B.A.T.M.A.N settings
|
||||||
ENABLE_BATMAN="no"
|
ENABLE_BATMAN="no"
|
||||||
BATMAN_IPV6=
|
BATMAN_IPV6=
|
||||||
MESH_ESSID=
|
|
||||||
|
|
||||||
# social key management
|
# social key management
|
||||||
ENABLE_SOCIAL_KEY_MANAGEMENT="no"
|
ENABLE_SOCIAL_KEY_MANAGEMENT="no"
|
||||||
|
@ -738,9 +737,6 @@ function read_configuration {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f $CONFIGURATION_FILE ]; then
|
if [ -f $CONFIGURATION_FILE ]; then
|
||||||
if grep -q "MESH_ESSID" $CONFIGURATION_FILE; then
|
|
||||||
MESH_ESSID=$(grep "MESH_ESSID" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
|
||||||
fi
|
|
||||||
if grep -q "TOX_PORT" $CONFIGURATION_FILE; then
|
if grep -q "TOX_PORT" $CONFIGURATION_FILE; then
|
||||||
TOX_PORT=$(grep "TOX_PORT" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
TOX_PORT=$(grep "TOX_PORT" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||||||
fi
|
fi
|
||||||
|
@ -1560,22 +1556,14 @@ function mesh_cjdns_tools {
|
||||||
|
|
||||||
function get_batman_ipv6_address {
|
function get_batman_ipv6_address {
|
||||||
if [ -f /home/$MY_USERNAME/README ]; then
|
if [ -f /home/$MY_USERNAME/README ]; then
|
||||||
if grep -q "BATMAN IPv6 address" /home/$MY_USERNAME/README; then
|
if grep -q "Mesh internet bridge IP address" /home/$MY_USERNAME/README; then
|
||||||
if [ ! $BATMAN_IPV6 ]; then
|
if [ ! $BATMAN_IPV6 ]; then
|
||||||
BATMAN_IPV6=$(cat /home/$MY_USERNAME/README | grep "BATMAN IPv6 address" | awk -F ':' '{print $2}' | sed 's/^ *//')
|
BATMAN_IPV6=$(cat /home/$MY_USERNAME/README | grep "Mesh internet bridge IP address" | awk -F ':' '{print $2}' | sed 's/^ *//')
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_mesh_essid {
|
|
||||||
if [ -f /home/$MY_USERNAME/README ]; then
|
|
||||||
if grep -q 'Mesh ESSID:' /home/$MY_USERNAME/README; then
|
|
||||||
MESH_ESSID==$(cat /home/$MY_USERNAME/README | grep "Mesh ESSID" | awk -F ':' '{print $2}' | sed 's/^ *//')
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function mesh_batman_bridge {
|
function mesh_batman_bridge {
|
||||||
# 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/
|
||||||
|
@ -1625,11 +1613,6 @@ function mesh_batman_bridge {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
get_mesh_essid
|
|
||||||
if [ ! $MESH_ESSID ]; then
|
|
||||||
MESH_ESSID="$(openssl rand -base64 5)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo '#!/bin/bash' > /usr/bin/mesh
|
echo '#!/bin/bash' > /usr/bin/mesh
|
||||||
echo '' > /usr/bin/mesh
|
echo '' > /usr/bin/mesh
|
||||||
echo '# stop network manager to make the mesh network work' >> /usr/bin/mesh
|
echo '# stop network manager to make the mesh network work' >> /usr/bin/mesh
|
||||||
|
@ -1643,7 +1626,7 @@ function mesh_batman_bridge {
|
||||||
echo 'iwconfig wlan0 enc off' >> /usr/bin/mesh
|
echo 'iwconfig wlan0 enc off' >> /usr/bin/mesh
|
||||||
echo '' >> /usr/bin/mesh
|
echo '' >> /usr/bin/mesh
|
||||||
echo '# add the interface to the ad-hoc network - or create it.' >> /usr/bin/mesh
|
echo '# add the interface to the ad-hoc network - or create it.' >> /usr/bin/mesh
|
||||||
echo -n "iwconfig wlan0 mode ad-hoc essid mesh-$MESH_ESSID ap " >> /usr/bin/mesh
|
echo -n "iwconfig wlan0 mode ad-hoc essid mesh ap " >> /usr/bin/mesh
|
||||||
echo "$BATMAN_IPV6 channel 2" >> /usr/bin/mesh
|
echo "$BATMAN_IPV6 channel 2" >> /usr/bin/mesh
|
||||||
echo '' >> /usr/bin/mesh
|
echo '' >> /usr/bin/mesh
|
||||||
echo -n '# add wlan0 to the batman-adv virtual interface(so it can ' >> /usr/bin/mesh
|
echo -n '# add wlan0 to the batman-adv virtual interface(so it can ' >> /usr/bin/mesh
|
||||||
|
@ -1669,8 +1652,8 @@ function mesh_batman_bridge {
|
||||||
echo '' >> /home/$MY_USERNAME/README
|
echo '' >> /home/$MY_USERNAME/README
|
||||||
echo 'Mesh Networking (B.A.T.M.A.N)' >> /home/$MY_USERNAME/README
|
echo 'Mesh Networking (B.A.T.M.A.N)' >> /home/$MY_USERNAME/README
|
||||||
echo '=============================' >> /home/$MY_USERNAME/README
|
echo '=============================' >> /home/$MY_USERNAME/README
|
||||||
echo "Mesh ESSID: $MESH_ESSID" >> /home/$MY_USERNAME/README
|
echo 'Mesh ESSID: mesh' >> /home/$MY_USERNAME/README
|
||||||
echo "BATMAN IPv6 address: $BATMAN_IPV6" >> /home/$MY_USERNAME/README
|
echo "Mesh internet bridge IP address: $BATMAN_IPV6" >> /home/$MY_USERNAME/README
|
||||||
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
|
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
|
||||||
chmod 600 /home/$MY_USERNAME/README
|
chmod 600 /home/$MY_USERNAME/README
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -31,6 +31,9 @@ CURR_USER=$USER
|
||||||
# Version number of this script
|
# Version number of this script
|
||||||
VERSION="1.01"
|
VERSION="1.01"
|
||||||
|
|
||||||
|
# mesh networking settings
|
||||||
|
BATMAN_IPV6=
|
||||||
|
|
||||||
# ssh (from https://stribika.github.io/2015/01/04/secure-secure-shell.html)
|
# 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"
|
SSH_CIPHERS="chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr"
|
||||||
SSH_MACS="hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-ripemd160-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-ripemd160,umac-128@openssh.com"
|
SSH_MACS="hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-ripemd160-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-ripemd160,umac-128@openssh.com"
|
||||||
|
@ -79,6 +82,81 @@ function configure_ssh_client {
|
||||||
echo ''
|
echo ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mesh_batman {
|
||||||
|
if [ ! $BATMAN_IPV6 ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
sudo apt-get -y install iproute bridge-utils libnetfilter-conntrack3 batctl
|
||||||
|
sudo apt-get -y install python-dev libevent-dev ebtables python-pip git
|
||||||
|
|
||||||
|
sudo modprobe batman-adv
|
||||||
|
[ $? -ne 0 ] && echo "B.A.T.M.A.N module not available" && exit 76482
|
||||||
|
if ! grep -q "batman_adv" /etc/modules; then
|
||||||
|
sudo echo 'batman_adv' >> /etc/modules
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo '#!/bin/bash' > /tmp/freedombone_mesh
|
||||||
|
echo '' > /tmp/freedombone_mesh
|
||||||
|
echo '# stop network manager to make the mesh network work' >> /tmp/freedombone_mesh
|
||||||
|
echo 'service networking stop' >> /tmp/freedombone_mesh
|
||||||
|
echo '' >> /tmp/freedombone_mesh
|
||||||
|
echo -n '# configure the wlan interface to operate with ' >> /tmp/freedombone_mesh
|
||||||
|
echo 'mtus of 1532(batman requires it) and turn enc off ' >> /tmp/freedombone_mesh
|
||||||
|
echo 'to ensure it works' >> /tmp/freedombone_mesh
|
||||||
|
echo 'ifconfig wlan0 down' >> /tmp/freedombone_mesh
|
||||||
|
echo 'ifconfig wlan0 mtu 1532' >> /tmp/freedombone_mesh
|
||||||
|
echo 'iwconfig wlan0 enc off' >> /tmp/freedombone_mesh
|
||||||
|
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 '' >> /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
|
||||||
|
echo 'batctl if add wlan0' >> /tmp/freedombone_mesh
|
||||||
|
echo 'ifconfig wlan0 up' >> /tmp/freedombone_mesh
|
||||||
|
echo 'ifconfig bat0 up' >> /tmp/freedombone_mesh
|
||||||
|
echo '' >> /tmp/freedombone_mesh
|
||||||
|
echo '# get the ip address for the node from the bridge connected to the dhcp server' >> /tmp/freedombone_mesh
|
||||||
|
echo 'dhclient bat0' >> /tmp/freedombone_mesh
|
||||||
|
echo '' >> /tmp/freedombone_mesh
|
||||||
|
echo 'exit 0' >> /tmp/freedombone_mesh
|
||||||
|
chmod +x /tmp/freedombone_mesh
|
||||||
|
sudo mv /tmp/freedombone_mesh /usr/bin/mesh
|
||||||
|
}
|
||||||
|
|
||||||
|
function show_help {
|
||||||
|
echo ''
|
||||||
|
echo 'freedombone-client --mesh-ip [mesh bridge IPv6 address]'
|
||||||
|
echo ''
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
while [[ $# > 1 ]]
|
||||||
|
do
|
||||||
|
key="$1"
|
||||||
|
|
||||||
|
case $key in
|
||||||
|
-h|--help)
|
||||||
|
show_help
|
||||||
|
;;
|
||||||
|
--mesh-ip)
|
||||||
|
shift
|
||||||
|
BATMAN_IPV6="$1"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# unknown option
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
echo 'Configuring client'
|
echo 'Configuring client'
|
||||||
configure_ssh_client
|
configure_ssh_client
|
||||||
|
mesh_batman
|
||||||
echo 'Configuration complete'
|
echo 'Configuration complete'
|
||||||
|
if [[ $BATMAN_IPV6 ]]; then
|
||||||
|
echo ''
|
||||||
|
echo 'Type "sudo mesh" to connect to the mesh network'
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
|
|
@ -90,7 +90,6 @@ USB_DRIVE=/dev/sdb1
|
||||||
HWRNG_TYPE=
|
HWRNG_TYPE=
|
||||||
ENABLE_SOCIAL_KEY_MANAGEMENT=
|
ENABLE_SOCIAL_KEY_MANAGEMENT=
|
||||||
BATMAN_IPV6=
|
BATMAN_IPV6=
|
||||||
MESH_ESSID=
|
|
||||||
|
|
||||||
CONFIGURATION_FILE=
|
CONFIGURATION_FILE=
|
||||||
|
|
||||||
|
@ -232,9 +231,6 @@ function save_configuration_file {
|
||||||
if [ $BATMAN_IPV6 ]; then
|
if [ $BATMAN_IPV6 ]; then
|
||||||
echo "BATMAN_IPV6=$BATMAN_IPV6" >> $CONFIGURATION_FILE
|
echo "BATMAN_IPV6=$BATMAN_IPV6" >> $CONFIGURATION_FILE
|
||||||
fi
|
fi
|
||||||
if [ $MESH_ESSID ]; then
|
|
||||||
echo "MESH_ESSID=$MESH_ESSID" >> $CONFIGURATION_FILE
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# test a domain name to see if it's valid
|
# test a domain name to see if it's valid
|
||||||
|
@ -1388,9 +1384,6 @@ function read_configuration {
|
||||||
if grep -q "ENABLE_BATMAN" $CONFIGURATION_FILE; then
|
if grep -q "ENABLE_BATMAN" $CONFIGURATION_FILE; then
|
||||||
ENABLE_BATMAN=$(grep "ENABLE_BATMAN" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
ENABLE_BATMAN=$(grep "ENABLE_BATMAN" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||||||
fi
|
fi
|
||||||
if grep -q "MESH_ESSID" $CONFIGURATION_FILE; then
|
|
||||||
MESH_ESSID=$(grep "MESH_ESSID" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
|
||||||
fi
|
|
||||||
if grep -q "BATMAN_IPV6" $CONFIGURATION_FILE; then
|
if grep -q "BATMAN_IPV6" $CONFIGURATION_FILE; then
|
||||||
BATMAN_IPV6=$(grep "BATMAN_IPV6" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
BATMAN_IPV6=$(grep "BATMAN_IPV6" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue