use . /var/state/network instead of config_load to avoid a CONFIG_SECTIONS reset
[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 . /var/state/network
8 config_get ifname wan ifname
9 config_get ipaddr lan ipaddr
10
11 echo "miniupnpd starting ..."
12 stop
13 iptables_init.sh
14 # get bitspeed information, if provided
15 config_get upnp_up_bitspeed config upload
16 config_get upnp_down_bitspeed config download
17 bitspeed_str=""
18 [ -n "$upnpd_up_bitspeed" ] && [ -n "$upnpd_down_bitspeed" ] && {
19 # covert to bytespeed
20 upnpd_up_bytespeed=$(($upnpd_up_bitspeed * 1024 / 8))
21 upnpd_down_bytespeed=$(($upnpd_down_bitspeed * 1024 / 8))
22 bitspeed_str="-B $upnpd_down_bytespeed $upnpd_up_bytespeed"
23 }
24 config_get log_output config log_output
25 if [ "$log_output" = "1" ]; then
26 miniupnpd -i "$ifname" -a "$ipaddr" -p 5000 -U $bitspeed_str -d | logger -t miniupnpd &
27 else
28 miniupnpd -i "$ifname" -a "$ipaddr" -p 5000 -U $bitspeed_str
29 fi
30 }
31
32 stop() {
33 pnpd_pid=$(cat /var/run/miniupnpd.pid) 2>&- >&-
34 iptables_flush.sh 2>&- >&-
35 kill $pnpd_pid 2>&-
36 iptables_removeall.sh 2>&- >&-
37 }