| #! /bin/sh |
| |
| guesswan() |
| { |
| line=$(ip route show | grep ^default) |
| # eg: "default via 192.168.5.1 dev wan0 " |
| line=${line##* dev } |
| line=${line%% *} |
| echo $line |
| } |
| |
| makeconf() |
| { |
| local wan |
| wan="$1" |
| ( |
| echo "quickleave" |
| echo "phyint $wan upstream ratelimit 0 threshold 1" |
| echo " altnet 0.0.0.0/0" |
| echo "phyint br0 downstream ratelimit 0 threshold 1" |
| ) > /etc/igmpproxy.conf |
| } |
| |
| wan=$(guesswan) |
| if [ -z "$wan" ]; then |
| echo "No wan detected, igmpproxy will not start" 1>&2 |
| exit 1 |
| fi |
| |
| makeconf "$wan" |
| |
| # igmpproxy will fail if there are no ipv4 addresses on wan0 or br0 |
| # babysitter (in S48igmpproxy) should restart it until there are |
| exec igmpproxy -d /etc/igmpproxy.conf |