Allow mesh on an interface other than wlanX

This commit is contained in:
Bob Mottram 2018-03-07 15:59:09 +00:00
parent 9f14c00645
commit e209eef34e
2 changed files with 59 additions and 37 deletions

View File

@ -74,6 +74,7 @@ function stop {
# shellcheck disable=SC2153
if [ "$EIFACE" ]; then
if [[ "$EIFACE" != "$IFACE" ]] ; then
brctl delif "$BRIDGE" bat0
ifconfig "$BRIDGE" down || true
ethernet_connected=$(cat "/sys/class/net/$EIFACE/carrier")
@ -84,13 +85,16 @@ function stop {
fi
brctl delbr "$BRIDGE"
fi
fi
ifconfig bat0 down -promisc
batctl if del "$IFACE"
ifconfig "$IFACE" mtu 1500
ifconfig "$IFACE" down
if [[ "$MESH_INTERFACE_TYPE" == 'wlan'* ]]; then
iwconfig "$IFACE" mode managed
fi
if [ "$IFACE_SECONDARY" ]; then
systemctl stop hostapd
@ -98,8 +102,10 @@ function stop {
batctl if del "$IFACE_SECONDARY"
ifconfig "$IFACE_SECONDARY" mtu 1500
ifconfig "$IFACE_SECONDARY" down
if [[ "$MESH_INTERFACE_TYPE" == 'wlan'* ]]; then
iwconfig "$IFACE_SECONDARY" mode managed
fi
fi
rmmod batman-adv
@ -149,8 +155,10 @@ function add_wifi_interface {
fi
ifconfig "$ifname" hw ether "$peermac"
echo $"$ifname assigned MAC address $peermac"
if [[ "$MESH_INTERFACE_TYPE" == 'wlan'* ]]; then
iwconfig "$ifname" enc off
iwconfig "$ifname" mode "$ifmode" essid "$ifssid" channel "$ifchannel"
fi
batctl if add "$ifname"
ifconfig "$ifname" up
@ -184,6 +192,7 @@ function start {
rfkill unblock "$(rfkill list|awk -F: "/phy/ {print $1}")" || true
secondary_wifi_available=
if [[ "$MESH_INTERFACE_TYPE" == 'wlan'* ]]; then
if [ "$IFACE_SECONDARY" ]; then
if [[ "$IFACE" != "$IFACE_SECONDARY" ]]; then
if [ -d /etc/hostapd ]; then
@ -195,6 +204,7 @@ function start {
fi
fi
fi
fi
modprobe batman-adv
@ -219,6 +229,7 @@ function start {
ifconfig bat0 0.0.0.0
ethernet_connected='0'
if [ "$EIFACE" ] ; then
if [[ "$EIFACE" != "$IFACE" ]] ; then
ethernet_connected=$(cat "/sys/class/net/$EIFACE/carrier")
if [[ "$ethernet_connected" != "0" ]]; then
echo $'Trying ethernet bridge to the internet'
@ -236,6 +247,7 @@ function start {
echo $"$EIFACE is not connected"
fi
fi
fi
ifconfig "$BRIDGE" up
dhclient "$BRIDGE"
@ -292,6 +304,9 @@ function start {
}
function monitor {
if [[ "$MESH_INTERFACE_TYPE" != 'wlan'* ]]; then
return
fi
if [ -z "$IFACE" ] ; then
echo 'error: unable to find wifi interface, not enabling batman-adv mesh'
exit 723657
@ -360,6 +375,11 @@ if [ -f "$mesh_interface_type_file" ]; then
fi
mesh_protocol_init
if [[ "$MESH_INTERFACE_TYPE" == 'eth'* ]]; then
MESH_INTERFACE_TYPE='eth'
fi
update_wifi_adaptors "${MESH_INTERFACE_TYPE}"
if [ ! "$IFACE" ]; then

View File

@ -99,12 +99,14 @@ function mesh_protocol_init {
IFACE=
IFACE_SECONDARY=
EIFACE=eth0
if [[ "$MESH_INTERFACE_TYPE" == 'wlan'* ]]; then
WLAN_ADAPTORS=$(count_wlan)
if [ "$WLAN_ADAPTORS" -eq 0 ]; then
echo $'No wlan adaptors found'
exit 0
fi
fi
}
function get_ipv6_wlan {