update miniupnpd to 20070112
[openwrt/svn-archive/archive.git] / net / miniupnpd / files / miniupnpd.init
1 #!/bin/sh /etc/rc.common
2 START=95
3 start() {
4 config_load "upnpd"
5 include /lib/network
6 scan_interfaces
7 config_get ifname wan ifname
8 config_get ipaddr lan ipaddr
9
10 echo "miniupnpd starting ..."
11 stop
12 iptables_init.sh
13 # get bitspeed information, if provided
14 config_get upnp_up_bitspeed config upload
15 config_get upnp_down_bitspeed config download
16 bitspeed_str=""
17 [ -n "$upnpd_up_bitspeed" ] && [ -n "$upnpd_down_bitspeed" ] && {
18 # covert to bytespeed
19 upnpd_up_bytespeed=$(($upnpd_up_bitspeed * 1024 / 8))
20 upnpd_down_bytespeed=$(($upnpd_down_bitspeed * 1024 / 8))
21 bitspeed_str="-B $upnpd_down_bytespeed $upnpd_up_bytespeed"
22 }
23 config_get log_output config log_output
24 if [ "$log_output" = "1" ]; then
25 miniupnpd -i "$ifname" -a "$ipaddr" -p 5000 -U $bitspeed_str -d | logger -t miniupnpd &
26 else
27 miniupnpd -i "$ifname" -a "$ipaddr" -p 5000 -U $bitspeed_str
28 fi
29 }
30
31 stop() {
32 pnpd_pid=$(cat /var/run/miniupnpd.pid) 2>&- >&-
33 iptables_flush.sh 2>&- >&-
34 kill $pnpd_pid 2>&-
35 iptables_removeall.sh 2>&- >&-
36 }