2014-06-26 11:43:34 +00:00
|
|
|
#!/bin/sh /etc/rc.common
|
|
|
|
# Copyright (c) 2014 OpenWrt.org
|
|
|
|
|
|
|
|
START=80
|
|
|
|
|
|
|
|
USE_PROCD=1
|
2017-02-15 10:46:57 +00:00
|
|
|
PROG=/usr/sbin/umdns
|
2014-06-26 11:43:34 +00:00
|
|
|
IFACES=""
|
|
|
|
|
|
|
|
load_ifaces() {
|
2024-02-11 22:44:42 +00:00
|
|
|
local network="$(uci -q get umdns.@umdns[-1].network)"
|
2014-06-26 11:43:34 +00:00
|
|
|
for n in $network; do
|
|
|
|
local device
|
2015-09-02 09:23:52 +00:00
|
|
|
json_load "$(ifstatus $n)"
|
2014-06-26 11:43:34 +00:00
|
|
|
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
|
|
|
|
|
2017-02-15 10:46:57 +00:00
|
|
|
ubus call umdns set_config "$(json_dump)"
|
2014-06-26 11:43:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
start_service() {
|
2024-02-11 22:44:42 +00:00
|
|
|
local network="$(uci -q get umdns.@umdns[-1].network)"
|
2014-06-26 11:43:34 +00:00
|
|
|
|
|
|
|
procd_open_instance
|
|
|
|
procd_set_param command "$PROG"
|
2020-11-27 13:49:43 +00:00
|
|
|
[ -f /etc/seccomp/umdns.json ] && procd_set_param seccomp /etc/seccomp/umdns.json
|
2014-06-26 11:43:34 +00:00
|
|
|
procd_set_param respawn
|
|
|
|
procd_open_trigger
|
2017-02-15 10:46:57 +00:00
|
|
|
procd_add_config_trigger "config.change" "umdns" /etc/init.d/umdns reload
|
2014-06-26 11:43:34 +00:00
|
|
|
for n in $network; do
|
2017-02-15 10:46:57 +00:00
|
|
|
procd_add_interface_trigger "interface.*" $n /etc/init.d/umdns reload
|
2014-06-26 11:43:34 +00:00
|
|
|
done
|
2017-02-15 10:46:57 +00:00
|
|
|
procd_add_raw_trigger "instance.update" 5000 "/bin/ubus" "call" "umdns" "reload"
|
2014-06-26 11:43:34 +00:00
|
|
|
procd_close_trigger
|
2024-03-20 19:22:46 +00:00
|
|
|
[ "$(uci get umdns.@umdns[-1].jail)" = 1 ] && {
|
|
|
|
procd_add_jail umdns ubus log
|
|
|
|
[ -d /etc/umdns ] && procd_add_jail_mount "/etc/umdns"
|
|
|
|
}
|
2014-06-26 11:43:34 +00:00
|
|
|
procd_close_instance
|
|
|
|
}
|
|
|
|
|
|
|
|
service_started() {
|
2017-02-15 10:46:57 +00:00
|
|
|
ubus -t 10 wait_for umdns
|
2014-06-26 11:43:34 +00:00
|
|
|
[ $? = 0 ] && reload_service
|
|
|
|
}
|