aboutsummaryrefslogtreecommitdiffstats
path: root/package/network/services/mdns/files/mdns.init
diff options
context:
space:
mode:
authorJames <>2015-11-04 11:49:21 +0000
committerJames <>2015-11-04 11:49:21 +0000
commit716ca530e1c4515d8683c9d5be3d56b301758b66 (patch)
tree700eb5bcc1a462a5f21dcec15ce7c97ecfefa772 /package/network/services/mdns/files/mdns.init
downloadtrunk-47381-716ca530e1c4515d8683c9d5be3d56b301758b66.tar.gz
trunk-47381-716ca530e1c4515d8683c9d5be3d56b301758b66.tar.bz2
trunk-47381-716ca530e1c4515d8683c9d5be3d56b301758b66.zip
trunk-47381HEADmaster
Diffstat (limited to 'package/network/services/mdns/files/mdns.init')
-rw-r--r--package/network/services/mdns/files/mdns.init54
1 files changed, 54 insertions, 0 deletions
diff --git a/package/network/services/mdns/files/mdns.init b/package/network/services/mdns/files/mdns.init
new file mode 100644
index 0000000..c0f9155
--- /dev/null
+++ b/package/network/services/mdns/files/mdns.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/mdns
+IFACES=""
+
+load_ifaces() {
+ local network="$(uci get mdns.@mdns[-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 mdns set_config "$(json_dump)"
+}
+
+start_service() {
+ local network="$(uci get mdns.@mdns[-1].network)"
+
+ procd_open_instance
+ procd_set_param command "$PROG"
+ procd_set_param seccomp /etc/seccomp/mdns.json
+ procd_set_param respawn
+ procd_open_trigger
+ procd_add_config_trigger "config.change" "mdns" /etc/init.d/mdns reload
+ for n in $network; do
+ procd_add_interface_trigger "interface.*" $n /etc/init.d/mdns reload
+ done
+ procd_add_raw_trigger "instance.update" 5000 "/bin/ubus" "call" "mdns" "reload"
+ procd_close_trigger
+ [ "$(uci get mdns.@mdns[-1].jail)" = 1 ] && procd_add_jail mdns ubus log
+ procd_close_instance
+}
+
+service_started() {
+ ubus -t 10 wait_for mdns
+ [ $? = 0 ] && reload_service
+}