aboutsummaryrefslogtreecommitdiffstats
path: root/package/network/services/umdns/files/umdns.init
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2017-02-15 11:46:57 +0100
committerRafał Miłecki <rafal@milecki.pl>2017-02-15 13:07:21 +0100
commitdf49e49bc7834ad3257d1b10972854a14605a67c (patch)
treee421b8b0f0d8666687c606df479a847e11a01c04 /package/network/services/umdns/files/umdns.init
parent72d045b2a6104dfbb18e519044048c622dc29a82 (diff)
downloadupstream-df49e49bc7834ad3257d1b10972854a14605a67c.tar.gz
upstream-df49e49bc7834ad3257d1b10972854a14605a67c.tar.bz2
upstream-df49e49bc7834ad3257d1b10972854a14605a67c.zip
mdns: update and rename package to the umdns
This update includes numerous small fixes for: 1) Interfaces setup 2) Packets parsing 3) Sending replies Without this there were multiple problems with exchanging information between (u)mdns and other implementations (including (u)mdns as well). This also follows project rename to umdns which was required to avoid confusion with Apple's mdnsd from mDNSResponder project. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Diffstat (limited to 'package/network/services/umdns/files/umdns.init')
-rw-r--r--package/network/services/umdns/files/umdns.init54
1 files changed, 54 insertions, 0 deletions
diff --git a/package/network/services/umdns/files/umdns.init b/package/network/services/umdns/files/umdns.init
new file mode 100644
index 0000000000..627930b88d
--- /dev/null
+++ b/package/network/services/umdns/files/umdns.init
@@ -0,0 +1,54 @@
+#!/bin/sh /etc/rc.common
+# Copyright (c) 2014 OpenWrt.org
+
+. /lib/functions/network.sh
+
+START=80
+
+USE_PROCD=1
+PROG=/usr/sbin/umdns
+IFACES=""
+
+load_ifaces() {
+ local network="$(uci get umdns.@umdns[-1].network)"
+ for n in $network; do
+ local device
+ json_load "$(ifstatus $n)"
+ json_get_var device l3_device
+ echo -n "$device "
+ done
+}
+
+reload_service() {
+ json_init
+ json_add_array interfaces
+ for i in $(load_ifaces); do
+ json_add_string "" "$i"
+ done
+ json_close_array
+
+ ubus call umdns set_config "$(json_dump)"
+}
+
+start_service() {
+ local network="$(uci get umdns.@umdns[-1].network)"
+
+ procd_open_instance
+ procd_set_param command "$PROG"
+ procd_set_param seccomp /etc/seccomp/umdns.json
+ procd_set_param respawn
+ procd_open_trigger
+ procd_add_config_trigger "config.change" "umdns" /etc/init.d/umdns reload
+ for n in $network; do
+ procd_add_interface_trigger "interface.*" $n /etc/init.d/umdns reload
+ done
+ procd_add_raw_trigger "instance.update" 5000 "/bin/ubus" "call" "umdns" "reload"
+ procd_close_trigger
+ [ "$(uci get umdns.@umdns[-1].jail)" = 1 ] && procd_add_jail umdns ubus log
+ procd_close_instance
+}
+
+service_started() {
+ ubus -t 10 wait_for umdns
+ [ $? = 0 ] && reload_service
+}