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