mirror of
https://github.com/novatiq/packages.git
synced 2026-04-30 07:28:39 +01:00
wg-installer: add babeld hotplug.d script
Add a hotplug.d-extension that automatically configures babeld for meshing via wireguard interfaces. It checks for "add" and "remove" of a wireguard interface with name "wg_*". Depending on the action, it removes it from the babeld config or adds the interface and reloads babeld. Signed-off-by: Nick Hainke <vincent@systemli.org>
This commit is contained in:
committed by
Polynomdivision
parent
6b9fdf2e77
commit
3ebc568f18
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
# check if wireguard
|
||||
if [ "${DEVTYPE}" != "wireguard" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# check if correct naming
|
||||
slicedint=$(echo $INTERFACE | cut -c1-3)
|
||||
if [ "${slicedint}" != "wg_" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${ACTION}" == "add" ]; then
|
||||
uci add babeld interface
|
||||
uci set babeld.@interface[-1].ifname="${INTERFACE}"
|
||||
uci commit
|
||||
/etc/init.d/babeld reload
|
||||
fi
|
||||
|
||||
if [ "${ACTION}" == "remove" ]; then
|
||||
i=0
|
||||
while uci get babeld.@interface[$i] &> /dev/null ; do
|
||||
if [ "$(uci get babeld.@interface[$i].ifname)" == "${INTERFACE}" ]; then
|
||||
uci delete babeld.@interface[$i]
|
||||
fi
|
||||
i=$((i+1));
|
||||
done
|
||||
uci commit
|
||||
/etc/init.d/babeld reload
|
||||
fi
|
||||
Reference in New Issue
Block a user