Allow mesh on an interface other than wlanX
This commit is contained in:
parent
9f14c00645
commit
e209eef34e
|
@ -74,15 +74,17 @@ function stop {
|
||||||
|
|
||||||
# shellcheck disable=SC2153
|
# shellcheck disable=SC2153
|
||||||
if [ "$EIFACE" ]; then
|
if [ "$EIFACE" ]; then
|
||||||
brctl delif "$BRIDGE" bat0
|
if [[ "$EIFACE" != "$IFACE" ]] ; then
|
||||||
ifconfig "$BRIDGE" down || true
|
brctl delif "$BRIDGE" bat0
|
||||||
ethernet_connected=$(cat "/sys/class/net/$EIFACE/carrier")
|
ifconfig "$BRIDGE" down || true
|
||||||
if [[ "$ethernet_connected" != "0" ]]; then
|
ethernet_connected=$(cat "/sys/class/net/$EIFACE/carrier")
|
||||||
systemctl stop hostapd
|
if [[ "$ethernet_connected" != "0" ]]; then
|
||||||
brctl delif "$BRIDGE" "$EIFACE"
|
systemctl stop hostapd
|
||||||
ifconfig "$EIFACE" down -promisc
|
brctl delif "$BRIDGE" "$EIFACE"
|
||||||
|
ifconfig "$EIFACE" down -promisc
|
||||||
|
fi
|
||||||
|
brctl delbr "$BRIDGE"
|
||||||
fi
|
fi
|
||||||
brctl delbr "$BRIDGE"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ifconfig bat0 down -promisc
|
ifconfig bat0 down -promisc
|
||||||
|
@ -90,7 +92,9 @@ function stop {
|
||||||
batctl if del "$IFACE"
|
batctl if del "$IFACE"
|
||||||
ifconfig "$IFACE" mtu 1500
|
ifconfig "$IFACE" mtu 1500
|
||||||
ifconfig "$IFACE" down
|
ifconfig "$IFACE" down
|
||||||
iwconfig "$IFACE" mode managed
|
if [[ "$MESH_INTERFACE_TYPE" == 'wlan'* ]]; then
|
||||||
|
iwconfig "$IFACE" mode managed
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$IFACE_SECONDARY" ]; then
|
if [ "$IFACE_SECONDARY" ]; then
|
||||||
systemctl stop hostapd
|
systemctl stop hostapd
|
||||||
|
@ -98,7 +102,9 @@ function stop {
|
||||||
batctl if del "$IFACE_SECONDARY"
|
batctl if del "$IFACE_SECONDARY"
|
||||||
ifconfig "$IFACE_SECONDARY" mtu 1500
|
ifconfig "$IFACE_SECONDARY" mtu 1500
|
||||||
ifconfig "$IFACE_SECONDARY" down
|
ifconfig "$IFACE_SECONDARY" down
|
||||||
iwconfig "$IFACE_SECONDARY" mode managed
|
if [[ "$MESH_INTERFACE_TYPE" == 'wlan'* ]]; then
|
||||||
|
iwconfig "$IFACE_SECONDARY" mode managed
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rmmod batman-adv
|
rmmod batman-adv
|
||||||
|
@ -149,8 +155,10 @@ function add_wifi_interface {
|
||||||
fi
|
fi
|
||||||
ifconfig "$ifname" hw ether "$peermac"
|
ifconfig "$ifname" hw ether "$peermac"
|
||||||
echo $"$ifname assigned MAC address $peermac"
|
echo $"$ifname assigned MAC address $peermac"
|
||||||
iwconfig "$ifname" enc off
|
if [[ "$MESH_INTERFACE_TYPE" == 'wlan'* ]]; then
|
||||||
iwconfig "$ifname" mode "$ifmode" essid "$ifssid" channel "$ifchannel"
|
iwconfig "$ifname" enc off
|
||||||
|
iwconfig "$ifname" mode "$ifmode" essid "$ifssid" channel "$ifchannel"
|
||||||
|
fi
|
||||||
|
|
||||||
batctl if add "$ifname"
|
batctl if add "$ifname"
|
||||||
ifconfig "$ifname" up
|
ifconfig "$ifname" up
|
||||||
|
@ -184,13 +192,15 @@ function start {
|
||||||
rfkill unblock "$(rfkill list|awk -F: "/phy/ {print $1}")" || true
|
rfkill unblock "$(rfkill list|awk -F: "/phy/ {print $1}")" || true
|
||||||
|
|
||||||
secondary_wifi_available=
|
secondary_wifi_available=
|
||||||
if [ "$IFACE_SECONDARY" ]; then
|
if [[ "$MESH_INTERFACE_TYPE" == 'wlan'* ]]; then
|
||||||
if [[ "$IFACE" != "$IFACE_SECONDARY" ]]; then
|
if [ "$IFACE_SECONDARY" ]; then
|
||||||
if [ -d /etc/hostapd ]; then
|
if [[ "$IFACE" != "$IFACE_SECONDARY" ]]; then
|
||||||
if [ ${#HOTSPOT_PASSPHRASE} -gt 4 ]; then
|
if [ -d /etc/hostapd ]; then
|
||||||
secondary_wifi_available=1
|
if [ ${#HOTSPOT_PASSPHRASE} -gt 4 ]; then
|
||||||
else
|
secondary_wifi_available=1
|
||||||
echo $'Hotspot passphrase is too short'
|
else
|
||||||
|
echo $'Hotspot passphrase is too short'
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -219,21 +229,23 @@ function start {
|
||||||
ifconfig bat0 0.0.0.0
|
ifconfig bat0 0.0.0.0
|
||||||
ethernet_connected='0'
|
ethernet_connected='0'
|
||||||
if [ "$EIFACE" ] ; then
|
if [ "$EIFACE" ] ; then
|
||||||
ethernet_connected=$(cat "/sys/class/net/$EIFACE/carrier")
|
if [[ "$EIFACE" != "$IFACE" ]] ; then
|
||||||
if [[ "$ethernet_connected" != "0" ]]; then
|
ethernet_connected=$(cat "/sys/class/net/$EIFACE/carrier")
|
||||||
echo $'Trying ethernet bridge to the internet'
|
if [[ "$ethernet_connected" != "0" ]]; then
|
||||||
brctl addif "$BRIDGE" "$EIFACE"
|
echo $'Trying ethernet bridge to the internet'
|
||||||
ifconfig "$EIFACE" 0.0.0.0
|
brctl addif "$BRIDGE" "$EIFACE"
|
||||||
ifconfig "$EIFACE" up promisc
|
ifconfig "$EIFACE" 0.0.0.0
|
||||||
echo $'End of internet bridge'
|
ifconfig "$EIFACE" up promisc
|
||||||
|
echo $'End of internet bridge'
|
||||||
|
|
||||||
sed -i "s|ExecStart=.*|ExecStart=/usr/sbin/bmx6 dev=${IFACE} dev=${EIFACE}|g" /etc/systemd/system/bmx6.service
|
sed -i "s|ExecStart=.*|ExecStart=/usr/sbin/bmx6 dev=${IFACE} dev=${EIFACE}|g" /etc/systemd/system/bmx6.service
|
||||||
sed -i "s|ExecStart=.*|ExecStart=/usr/sbin/bmx7 dev=${IFACE} dev=${EIFACE}|g" /etc/systemd/system/bmx7.service
|
sed -i "s|ExecStart=.*|ExecStart=/usr/sbin/bmx7 dev=${IFACE} dev=${EIFACE}|g" /etc/systemd/system/bmx7.service
|
||||||
sed -i "s|ExecStart=.*|ExecStart=/usr/local/sbin/olsrd2_static ${IFACE} ${EIFACE}|g" /etc/systemd/system/olsr2.service
|
sed -i "s|ExecStart=.*|ExecStart=/usr/local/sbin/olsrd2_static ${IFACE} ${EIFACE}|g" /etc/systemd/system/olsr2.service
|
||||||
sed -i "s|ExecStart=.*|ExecStart=/usr/local/bin/babeld ${IFACE} ${EIFACE}|g" /etc/systemd/system/babel.service
|
sed -i "s|ExecStart=.*|ExecStart=/usr/local/bin/babeld ${IFACE} ${EIFACE}|g" /etc/systemd/system/babel.service
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
else
|
else
|
||||||
echo $"$EIFACE is not connected"
|
echo $"$EIFACE is not connected"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
ifconfig "$BRIDGE" up
|
ifconfig "$BRIDGE" up
|
||||||
|
@ -292,6 +304,9 @@ function start {
|
||||||
}
|
}
|
||||||
|
|
||||||
function monitor {
|
function monitor {
|
||||||
|
if [[ "$MESH_INTERFACE_TYPE" != 'wlan'* ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
if [ -z "$IFACE" ] ; then
|
if [ -z "$IFACE" ] ; then
|
||||||
echo 'error: unable to find wifi interface, not enabling batman-adv mesh'
|
echo 'error: unable to find wifi interface, not enabling batman-adv mesh'
|
||||||
exit 723657
|
exit 723657
|
||||||
|
@ -360,6 +375,11 @@ if [ -f "$mesh_interface_type_file" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mesh_protocol_init
|
mesh_protocol_init
|
||||||
|
|
||||||
|
if [[ "$MESH_INTERFACE_TYPE" == 'eth'* ]]; then
|
||||||
|
MESH_INTERFACE_TYPE='eth'
|
||||||
|
fi
|
||||||
|
|
||||||
update_wifi_adaptors "${MESH_INTERFACE_TYPE}"
|
update_wifi_adaptors "${MESH_INTERFACE_TYPE}"
|
||||||
|
|
||||||
if [ ! "$IFACE" ]; then
|
if [ ! "$IFACE" ]; then
|
||||||
|
|
|
@ -99,11 +99,13 @@ function mesh_protocol_init {
|
||||||
IFACE=
|
IFACE=
|
||||||
IFACE_SECONDARY=
|
IFACE_SECONDARY=
|
||||||
EIFACE=eth0
|
EIFACE=eth0
|
||||||
WLAN_ADAPTORS=$(count_wlan)
|
if [[ "$MESH_INTERFACE_TYPE" == 'wlan'* ]]; then
|
||||||
|
WLAN_ADAPTORS=$(count_wlan)
|
||||||
|
|
||||||
if [ "$WLAN_ADAPTORS" -eq 0 ]; then
|
if [ "$WLAN_ADAPTORS" -eq 0 ]; then
|
||||||
echo $'No wlan adaptors found'
|
echo $'No wlan adaptors found'
|
||||||
exit 0
|
exit 0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue