1
0

umdns.init 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/sh /etc/rc.common
  2. # Copyright (c) 2014 OpenWrt.org
  3. START=80
  4. USE_PROCD=1
  5. PROG=/usr/sbin/umdns
  6. IFACES=""
  7. load_ifaces() {
  8. local network="$(uci get umdns.@umdns[-1].network)"
  9. for n in $network; do
  10. local device
  11. json_load "$(ifstatus $n)"
  12. json_get_var device l3_device
  13. echo -n "$device "
  14. done
  15. }
  16. reload_service() {
  17. json_init
  18. json_add_array interfaces
  19. for i in $(load_ifaces); do
  20. json_add_string "" "$i"
  21. done
  22. json_close_array
  23. ubus call umdns set_config "$(json_dump)"
  24. }
  25. start_service() {
  26. local network="$(uci get umdns.@umdns[-1].network)"
  27. procd_open_instance
  28. procd_set_param command "$PROG"
  29. procd_set_param seccomp /etc/seccomp/umdns.json
  30. procd_set_param respawn
  31. procd_open_trigger
  32. procd_add_config_trigger "config.change" "umdns" /etc/init.d/umdns reload
  33. for n in $network; do
  34. procd_add_interface_trigger "interface.*" $n /etc/init.d/umdns reload
  35. done
  36. procd_add_raw_trigger "instance.update" 5000 "/bin/ubus" "call" "umdns" "reload"
  37. procd_close_trigger
  38. [ "$(uci get umdns.@umdns[-1].jail)" = 1 ] && procd_add_jail umdns ubus log
  39. procd_close_instance
  40. }
  41. service_started() {
  42. ubus -t 10 wait_for umdns
  43. [ $? = 0 ] && reload_service
  44. }