udpxy.init 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2006-2014 OpenWrt.org
  3. START=50
  4. USE_PROCD=1
  5. append_arg() {
  6. local cfg="$1"
  7. local var="$2"
  8. local opt="$3"
  9. local def="$4"
  10. local val
  11. config_get val "$cfg" "$var"
  12. [ -n "$val" -o -n "$def" ] && procd_append_param command $opt "${val:-$def}"
  13. }
  14. append_bool() {
  15. local cfg="$1"
  16. local var="$2"
  17. local opt="$3"
  18. local def="$4"
  19. local val
  20. config_get_bool val "$cfg" "$var" "$def"
  21. [ "$val" = 1 ] && procd_append_param command "$opt"
  22. }
  23. start_instance() {
  24. local cfg="$1"
  25. local aux
  26. config_get_bool aux "$cfg" 'disabled' '0'
  27. [ "$aux" = 1 ] && return 1
  28. procd_open_instance
  29. procd_set_param command /usr/bin/udpxy
  30. procd_append_param command "-T"
  31. append_bool "$cfg" verbose "-V"
  32. append_bool "$cfg" status "-S"
  33. append_arg "$cfg" bind "-a"
  34. append_arg "$cfg" port "-p"
  35. append_arg "$cfg" source "-m"
  36. append_arg "$cfg" max_clients "-c"
  37. append_arg "$cfg" log_file "-l"
  38. append_arg "$cfg" buffer_size "-B"
  39. append_arg "$cfg" buffer_messages "-R"
  40. append_arg "$cfg" buffer_time "-H"
  41. append_arg "$cfg" nice_increment "-n"
  42. append_arg "$cfg" mcsub_renew "-M"
  43. config_get_bool aux "$cfg" 'respawn' '0'
  44. [ "$aux" = 1 ] && procd_set_param respawn
  45. procd_close_instance
  46. }
  47. service_triggers() {
  48. procd_add_reload_trigger "udpxy"
  49. }
  50. start_service() {
  51. config_load udpxy
  52. config_foreach start_instance udpxy
  53. }