1
0
mirror of https://git.openwrt.org/feed/packages.git synced 2024-06-17 21:03:56 +02:00

wg-installer: add hotplug script for olsr

Add hotplug-olsrd to automatically mesh with olsrd via new wireguard
links.

Signed-off-by: Nick Hainke <vincent@systemli.org>
This commit is contained in:
Nick Hainke 2022-01-06 22:03:18 +01:00
parent 59600bd5d6
commit d35c22951b
2 changed files with 44 additions and 0 deletions

View File

@ -62,6 +62,16 @@ define Package/wg-installer-server-hotplug-babeld/install
$(INSTALL_BIN) ./wg-server/hotplug.d/99-mesh-babeld $(1)/etc/hotplug.d/net/99-mesh-babeld
endef
define Package/wg-installer-server-hotplug-olsrd
$(call Package/wg-installer-server)
DEPENDS:=wg-installer-server
endef
define Package/wg-installer-server-hotplug-olsrd/install
$(INSTALL_DIR) $(1)/etc/hotplug.d/net/
$(INSTALL_BIN) ./wg-server/hotplug.d/99-mesh-olsrd $(1)/etc/hotplug.d/net/99-mesh-olsrd
endef
define Package/wg-installer-client
$(call Package/wg-installer/Default)
TITLE+= (client)
@ -86,4 +96,5 @@ endef
$(eval $(call BuildPackage,wg-installer-server))
$(eval $(call BuildPackage,wg-installer-server-hotplug-babeld))
$(eval $(call BuildPackage,wg-installer-server-hotplug-olsrd))
$(eval $(call BuildPackage,wg-installer-client))

View File

@ -0,0 +1,33 @@
#!/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 olsrd Interface
uci set olsrd.@Interface[-1].ignore=0
uci set olsrd.@Interface[-1].interface="${INTERFACE}"
uci set olsrd.@Interface[-1].Mode="ether"
uci commit
/etc/init.d/olsrd reload
fi
if [ "${ACTION}" == "remove" ]; then
i=0
while uci get olsrd.@Interface[$i] &> /dev/null ; do
if [ "$(uci get olsrd.@Interface[$i].interface)" == "${INTERFACE}" ]; then
uci delete olsrd.@Interface[$i]
fi
i=$((i+1));
done
uci commit
/etc/init.d/olsrd reload
fi