Last active
June 17, 2024 14:16
-
-
Save frafra/4952d8d1795b5732366c to your computer and use it in GitHub Desktop.
NetworkManager integration with batman-adv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# /etc/NetworkManager/dispatcher.d/05-batman | |
ESSID="Igloo mesh" | |
IFACE="wlp2s0" | |
ADDR="01:23:45:67:89:AB" | |
function current { | |
nmcli -t -f GENERAL.CONNECTION d show $IFACE | cut -d\: -f2 | |
} | |
interface=$1 | |
status=$2 | |
if [ ! "$interface" == $IFACE ]; then | |
exit 0 | |
fi | |
case $status in | |
up) | |
if [ "$(current)" == "$ESSID" ]; then | |
ip link set dev $IFACE mtu 1560 # 1500+60 | |
modprobe batman-adv | |
batctl if add $IFACE | |
batctl gw_mode client | |
# Keep the same MAC address (optional) | |
ip link set dev bat0 address $ADDR | |
ip link set dev bat0 up | |
#sleep 10 | |
# DHCP (optional) | |
dhclient -r | |
dhclient -H $(hostname) bat0 | |
fi | |
;; | |
down) | |
if [ ! "$(current)" == "$ESSID" ]; then | |
dhclient -r | |
ip link set dev bat0 down | |
batctl if del $IFACE | |
fi | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
# chmod 755 /etc/NetworkManager/dispatcher.d/05-batman