Skip to content

Instantly share code, notes, and snippets.

@frafra
Last active June 17, 2024 14:16
Show Gist options
  • Save frafra/4952d8d1795b5732366c to your computer and use it in GitHub Desktop.
Save frafra/4952d8d1795b5732366c to your computer and use it in GitHub Desktop.
NetworkManager integration with batman-adv
#!/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
@frafra
Copy link
Author

frafra commented Aug 4, 2015

# chmod 755 /etc/NetworkManager/dispatcher.d/05-batman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment