1
0

ucitrack 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/sh /etc/rc.common
  2. START=80
  3. USE_PROCD=1
  4. register_init() {
  5. local config="$1"
  6. local init="$2"
  7. shift; shift
  8. if [ -x "$init" ] && "$init" enabled && ! grep -sqE 'USE_PROCD=.' "$init"; then
  9. logger -t "ucitrack" "Setting up /etc/config/$config reload trigger for non-procd $init"
  10. procd_add_config_trigger "config.change" "$config" "$init" "$@"
  11. fi
  12. }
  13. register_trigger() {
  14. local sid="$1"
  15. local config init exec affects affected
  16. config_get config "$sid" TYPE
  17. config_get init "$sid" init
  18. config_get exec "$sid" exec
  19. config_get affects "$sid" affects
  20. if [ -n "$init" ]; then
  21. register_init "$config" "/etc/init.d/$init" "reload"
  22. fi
  23. if [ -n "$exec" ]; then
  24. case "$exec" in
  25. /etc/init.d/*)
  26. set -- $exec
  27. register_init "$config" "$@"
  28. ;;
  29. *)
  30. logger -t "ucitrack" "Setting up non-init /etc/config/$config reload handler: $exec"
  31. procd_add_config_trigger "config.change" "$config" "$exec"
  32. ;;
  33. esac
  34. fi
  35. for affected in $affects; do
  36. logger -t "ucitrack" "Setting up /etc/config/$config reload dependency on /etc/config/$affected"
  37. procd_add_config_trigger "config.change" "$affected" \
  38. ubus call service event \
  39. "$(printf '{"type":"config.change","data":{"package":"%s"}}' $config)"
  40. done
  41. }
  42. service_triggers() {
  43. config_foreach register_trigger
  44. }
  45. start_service() {
  46. config_load ucitrack
  47. }