6a2c0d15c4565ab0272c8d93d17a12f7579b9bfd
[openwrt/svn-archive/archive.git] / net / miniupnpd / files / miniupnpd.init
1 #!/bin/sh
2 upnpd_enabled=$(nvram get upnp_enabled)
3 if [ "$upnpd_enabled" = "1" ]; then
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=$(nvram get upnpd_up_bitspeed)
11 upnpd_down_bitspeed=$(nvram get upnpd_down_bitspeed)
12 [ -n "$upnpd_up_bitspeed" ] && [ -n "$upnpd_down_bitspeed" ] && {
13 # covert to bytespeed
14 let upnpd_up_bytespeed=$upnpd_up_bitspeed*1024/8
15 let upnpd_down_bytespeed=$upnpd_down_bitspeed*1024/8
16 bitspeed_str="-B $upnpd_down_bytespeed $upnpd_up_bytespeed"
17 }
18 upnpd_log=$(nvram get upnpd_log_output)
19 if [ "$upnpd_log" = "1" ]; then
20 miniupnpd -i $(nvram get wan_ifname) -a $(nvram get lan_ipaddr) -p 5000 -U "$bitspeed_str" -d | logger -t miniupnpd &
21 else
22 miniupnpd -i $(nvram get wan_ifname) -a $(nvram get lan_ipaddr) -p 5000 -U "$bitspeed_str"
23 fi
24 else
25 echo "miniupnpd service is disabled. Set nvram upnp_enabled to '1' to enable."
26 fi