umdns: add support to enable/disable mdns

update init script to:

* add support for enabling or disabling umdns
* add support for reload

 Signed-off-by: Mohd Husaam Mehdi <husaam.mehdi@iopsys.eu>
This commit is contained in:
Mohd Husaam Mehdi 2024-03-26 12:51:49 +05:30
parent 8a7239009c
commit bc49bcd611

View File

@ -18,6 +18,11 @@ load_ifaces() {
} }
reload_service() { reload_service() {
stop
start
}
configure_interfaces() {
json_init json_init
json_add_array interfaces json_add_array interfaces
for i in $(load_ifaces); do for i in $(load_ifaces); do
@ -29,6 +34,12 @@ reload_service() {
} }
start_service() { start_service() {
local disabled="$(uci -q get umdns.@umdns[-1].disabled)"
if [ "${disabled}" = "1" ] || [ "${disabled}" = "true" ]; then
return
fi
local network="$(uci -q get umdns.@umdns[-1].network)" local network="$(uci -q get umdns.@umdns[-1].network)"
procd_open_instance procd_open_instance
@ -46,10 +57,16 @@ start_service() {
procd_add_jail umdns ubus log procd_add_jail umdns ubus log
[ -d /etc/umdns ] && procd_add_jail_mount "/etc/umdns" [ -d /etc/umdns ] && procd_add_jail_mount "/etc/umdns"
} }
procd_close_instance procd_close_instance
} }
service_triggers()
{
procd_add_reload_trigger umdns
}
service_started() { service_started() {
ubus -t 10 wait_for umdns ubus -t 10 wait_for umdns
[ $? = 0 ] && reload_service [ $? = 0 ] && configure_interfaces
} }