| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- #!/bin/sh /etc/rc.common
- # Copyright (C) 2010-2014 OpenWrt.org
- START=99
- USE_PROCD=1
- PROG=/usr/sbin/igmpproxy
- CONFIGFILE=/var/etc/igmpproxy.conf
- # igmpproxy supports both a debug mode and verbosity, which are very useful
- # when something isn't working.
- #
- # Debug mode will print everything to stdout instead of syslog. Generally
- # verbosity should NOT be set as it will quickly fill your syslog.
- #
- # Put any debug or verbosity options into IGMP_OPTS
- #
- # Examples:
- # OPTIONS="-d -v -v" - debug mode and very verbose, this will land in
- # stdout and not in syslog
- # OPTIONS="-v" - be verbose, this will write aditional information to syslog
- OPTIONS=""
- igmp_header() {
- local quickleave
- config_get_bool quickleave "$1" quickleave 0
- mkdir -p /var/etc
- rm -f /var/etc/igmpproxy.conf
- [ $quickleave -gt 0 ] && echo "quickleave" >> /var/etc/igmpproxy.conf
- [ -L /etc/igmpproxy.conf ] || ln -nsf /var/etc/igmpproxy.conf /etc/igmpproxy.conf
- }
- igmp_add_phyint() {
- local network direction altnets device up
- config_get network $1 network
- config_get direction $1 direction
- config_get altnets $1 altnet
- json_load "$(ifstatus $network)"
- json_get_var device l3_device
- json_get_var up up
- [ -n "$device" -a "$up" = "1" ] || {
- procd_append_param error "$network is not up"
- return;
- }
- echo -e "\nphyint $device $direction ratelimit 0 threshold 1" >> /var/etc/igmpproxy.conf
- if [ -n "$altnets" ]; then
- local altnet
- for altnet in $altnets; do
- echo -e "\taltnet $altnet" >> /var/etc/igmpproxy.conf
- done
- fi
- }
- igmp_add_network() {
- local network
- config_get network $1 network
- procd_add_interface_trigger "interface.*" $network /etc/init.d/igmpproxy restart
- }
- service_triggers() {
- procd_add_reload_trigger "igmpproxy"
- }
- start_service() {
- config_load igmpproxy
- procd_open_instance
- config_foreach igmp_header igmpproxy
- config_foreach igmp_add_phyint phyint
- procd_set_param command $PROG
- [ -n "$OPTIONS" ] && procd_append_param $OPTIONS
- procd_append_param command $CONFIGFILE
- procd_set_param file $CONFIGFILE
- procd_set_param respawn
- procd_open_trigger
- config_foreach igmp_add_network phyint
- procd_close_trigger
- procd_close_instance
- }
|