5d307a9f4cab60a3c65f8f88c48d7bcaa5cb3de8
[openwrt/svn-archive/archive.git] / net / miniupnpd / files / miniupnpd.init
1 #!/bin/sh /etc/rc.common
2 START=95
3 start() {
4 echo "miniupnpd starting ..."
5 iptables_flush.sh 2>&- >&-
6 killall miniupnpd 2>&-
7 iptables_removeall.sh 2>&- >&-
8 iptables_init.sh
9 # get bitspeed information, if provided
10 upnpd_up_bitspeed=$(uci get upnpd.general.up_bitspeed)
11 upnpd_down_bitspeed=$(uci get upnpd.general.down_bitspeed)
12 bitspeed_str=""
13 [ -n "$upnpd_up_bitspeed" ] && [ -n "$upnpd_down_bitspeed" ] && {
14 # covert to bytespeed
15 let upnpd_up_bytespeed=$upnpd_up_bitspeed*1024/8
16 let upnpd_down_bytespeed=$upnpd_down_bitspeed*1024/8
17 bitspeed_str="-B $upnpd_down_bytespeed $upnpd_up_bytespeed"
18 }
19 upnpd_log=$(uci get upnpd.general.log_output)
20 if [ "$upnpd_log" = "1" ]; then
21 miniupnpd -i $(uci get network.wan.ifname) -a $(uci get network.lan.ipaddr) -p 5000 -U $bitspeed_str -d | logger -t miniupnpd &
22 else
23 miniupnpd -i $(uci get network.wan.ifname) -a $(uci get network.lan.ipaddr) -p 5000 -U $bitspeed_str
24 fi
25 }
26 stop() {
27 iptables_flush.sh 2>&- >&-
28 killall miniupnpd 2>&-
29 iptables_removeall.sh 2>&- >&-
30 }