lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # $Id: upnp.sh,v 1.22.6.1 2008-10-02 12:57:42 winfred Exp $ |
| 4 | # |
| 5 | # usage: upnp.sh |
| 6 | # |
| 7 | path_sh=`nv get path_sh` |
| 8 | . $path_sh/global.sh |
| 9 | echo "Info: upnp.sh start " >> $test_log |
| 10 | |
| 11 | |
| 12 | # stop all |
| 13 | killall -9 miniupnpd |
| 14 | sh $path_sh/upnp_ipt_remove.sh |
| 15 | |
| 16 | # upnp |
| 17 | upnp=`nv get upnpEnabled` |
| 18 | if [ "$upnp" = "1" ]; then |
| 19 | if [ -f $path_conf/pidfile/miniupnp.pid ] |
| 20 | then |
| 21 | rm -f $path_conf/pidfile/miniupnpd.pid |
| 22 | fi |
| 23 | |
| 24 | if [ -f /var/run/miniupnpd.pid ] |
| 25 | then |
| 26 | rm -f /var/run/miniupnpd.pid |
| 27 | fi |
| 28 | |
| 29 | if [ -f $path_conf/miniupnpd.conf ] |
| 30 | then |
| 31 | echo "$path_conf/miniupnpd.conf already exist!" |
| 32 | rm $path_conf/miniupnpd.conf |
| 33 | fi |
| 34 | |
| 35 | cp $path_ro/miniupnpd_temp.conf $path_conf/miniupnpd.conf |
| 36 | |
| 37 | gw=`nv get lan_ipaddr` |
| 38 | . $path_sh/upnp_set_listenip.sh $gw/16 |
| 39 | |
| 40 | route del -net 239.0.0.0 netmask 255.0.0.0 dev $lan_if |
| 41 | route add -net 239.0.0.0 netmask 255.0.0.0 dev $lan_if 2>>$test_log |
| 42 | if [ $? -ne 0 ];then |
| 43 | echo "Error: route add -net 239.0.0.0 netmask 255.0.0.0 dev $lan_if failed." >> $test_log |
| 44 | fi |
| 45 | . $path_sh/upnp_ipt_init.sh |
| 46 | miniupnpd -f $path_conf/miniupnpd.conf & |
| 47 | fi |