update miniupnpd to 20070112
[openwrt/svn-archive/archive.git] / net / miniupnpd / files / miniupnpd.init
index 5d307a9..446a37c 100644 (file)
@@ -1,30 +1,36 @@
 #!/bin/sh /etc/rc.common
 START=95
 start() {
 #!/bin/sh /etc/rc.common
 START=95
 start() {
+       config_load "upnpd"
+       include /lib/network
+       scan_interfaces
+       config_get ifname wan ifname
+       config_get ipaddr lan ipaddr
+       
        echo "miniupnpd starting ..."
        echo "miniupnpd starting ..."
-       iptables_flush.sh 2>&- >&-
-       killall miniupnpd 2>&-
-       iptables_removeall.sh 2>&- >&-
+       stop
        iptables_init.sh
        # get bitspeed information, if provided
        iptables_init.sh
        # get bitspeed information, if provided
-       upnpd_up_bitspeed=$(uci get upnpd.general.up_bitspeed)
-       upnpd_down_bitspeed=$(uci get upnpd.general.down_bitspeed)
+       config_get upnp_up_bitspeed config upload
+       config_get upnp_down_bitspeed config download
        bitspeed_str=""
        [ -n "$upnpd_up_bitspeed" ] && [ -n "$upnpd_down_bitspeed" ] && {
                # covert to bytespeed
        bitspeed_str=""
        [ -n "$upnpd_up_bitspeed" ] && [ -n "$upnpd_down_bitspeed" ] && {
                # covert to bytespeed
-               let upnpd_up_bytespeed=$upnpd_up_bitspeed*1024/8
-               let upnpd_down_bytespeed=$upnpd_down_bitspeed*1024/8
+               upnpd_up_bytespeed=$(($upnpd_up_bitspeed * 1024 / 8))
+               upnpd_down_bytespeed=$(($upnpd_down_bitspeed * 1024 / 8))
                bitspeed_str="-B $upnpd_down_bytespeed $upnpd_up_bytespeed"
        }
                bitspeed_str="-B $upnpd_down_bytespeed $upnpd_up_bytespeed"
        }
-       upnpd_log=$(uci get upnpd.general.log_output)
-       if [ "$upnpd_log" = "1" ]; then
-               miniupnpd -i $(uci get network.wan.ifname) -a $(uci get network.lan.ipaddr) -p 5000 -U $bitspeed_str -d | logger -t miniupnpd &
+       config_get log_output config log_output
+       if [ "$log_output" = "1" ]; then
+               miniupnpd -i "$ifname" -a "$ipaddr" -p 5000 -U $bitspeed_str -d | logger -t miniupnpd &
        else
        else
-               miniupnpd -i $(uci get network.wan.ifname) -a $(uci get network.lan.ipaddr) -p 5000 -U $bitspeed_str
+               miniupnpd -i "$ifname" -a "$ipaddr" -p 5000 -U $bitspeed_str
        fi
 }
        fi
 }
+
 stop() {
 stop() {
+       pnpd_pid=$(cat /var/run/miniupnpd.pid) 2>&- >&-
        iptables_flush.sh 2>&- >&-
        iptables_flush.sh 2>&- >&-
-       killall miniupnpd 2>&-
+       kill $pnpd_pid 2>&-
        iptables_removeall.sh 2>&- >&-
        iptables_removeall.sh 2>&- >&-
-}
\ No newline at end of file
+}