igmpproxy.init 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2010-2012 OpenWrt.org
  3. START=99
  4. STOP=10
  5. SERVICE_DAEMONIZE=1
  6. SERVICE_WRITE_PID=1
  7. # igmpproxy supports both a debug mode and verbosity, which are very useful
  8. # when something isn't working.
  9. #
  10. # Debug mode will print everything to stdout instead of syslog. Generally
  11. # verbosity should NOT be set as it will quickly fill your syslog.
  12. #
  13. # Put any debug or verbosity options into IGMP_OPTS
  14. #
  15. # Examples:
  16. # OPTIONS="-d -v -v" - debug mode and very verbose, this will land in
  17. # stdout and not in syslog
  18. # OPTIONS="-v" - be verbose, this will write aditional information to syslog
  19. OPTIONS=""
  20. igmp_header() {
  21. local quickleave
  22. config_get_bool quickleave "$1" quickleave 0
  23. mkdir -p /var/etc
  24. rm -f /var/etc/igmpproxy.conf
  25. [ $quickleave -gt 0 ] && echo "quickleave" >> /var/etc/igmpproxy.conf
  26. [ -L /etc/igmpproxy.conf ] || ln -nsf /var/etc/igmpproxy.conf /etc/igmpproxy.conf
  27. }
  28. igmp_add_phyint() {
  29. local network direction altnets
  30. config_get network $1 network
  31. config_get direction $1 direction
  32. config_get altnets $1 altnet
  33. device=$(uci_get_state network "$network" ifname "$network")
  34. echo -e "\nphyint $device $direction ratelimit 0 threshold 1" >> /var/etc/igmpproxy.conf
  35. if [ -n "$altnets" ]; then
  36. local altnet
  37. for altnet in $altnets; do
  38. echo -e "\taltnet $altnet" >> /var/etc/igmpproxy.conf
  39. done
  40. fi
  41. }
  42. start() {
  43. config_load igmpproxy
  44. config_foreach igmp_header igmpproxy
  45. config_foreach igmp_add_phyint phyint
  46. service_start /usr/sbin/igmpproxy $OPTIONS /etc/igmpproxy.conf
  47. }
  48. stop() {
  49. service_stop /usr/sbin/igmpproxy
  50. }