gluon-mmfd: add package (#1802)

This commit is contained in:
Christof Schulze 2019-09-23 21:34:53 +02:00 committed by Andreas Ziegler
parent dcfbbea090
commit 6aee8e95e8
2 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=gluon-mmfd
PKG_VERSION:=1
include ../gluon.mk
define Package/gluon-mmfd
TITLE:=Mesh multicast forwarding daemon - Gluon integration
DEPENDS:=+mmfd +uc +gluon-core
endef
$(eval $(call BuildPackageGluon,gluon-mmfd))

View File

@ -0,0 +1,60 @@
#!/bin/sh /etc/rc.common
USE_PROCD=1
START=50
DAEMON=/usr/sbin/mmfd
SOCKET=/var/run/mmfd.sock
start_service() {
local interfaces=$(for dev in $(gluon-list-mesh-interfaces); do echo " -i $dev"; done)
procd_open_instance
procd_set_param command $DAEMON -s $SOCKET $interfaces
procd_set_param respawn ${respawn_threshold:-60} ${respawn_timeout:-1} ${respawn_retry:-0}
procd_set_param stderr 1
procd_set_param stdout 1
procd_close_instance
}
mmfd_get_interfaces() {
echo get_meshifs | uc $SOCKET | jsonfilter -e "@.mesh_interfaces[@]"
}
mmfd_has_interface() {
mmfd_get_interfaces | grep -q "^$1$"
}
addif() {
echo "add_meshif $@" | uc $SOCKET
}
delif() {
echo "del_meshif $@" | uc $SOCKET
}
reload_service() {
waitforsocket
for i in $(ubus call network.interface dump | jsonfilter -e "@.interface[@.proto='gluon_mesh' && @.up=true].device")
do
if ! mmfd_has_interface $i; then
addif $i
fi
done
for i in $(mmfd_get_interfaces)
do
if ! ubus call network.interface dump | jsonfilter -e "@.interface[@.proto='gluon_mesh' && @.up=true].device" | grep -q "^$i$"; then
delif $i
fi
done
}
service_triggers() {
local script=$(readlink "$initscript")
local name=$(basename "${script:-$initscript}")
procd_open_trigger
procd_add_raw_trigger "interface.*" 0 "/etc/init.d/$name" reload
procd_close_trigger
}