1 #!/bin/sh /etc/rc.common
5 type miniupnpd_add_rules
>/dev
/null
2>/dev
/null || \
6 ACTION
=- .
/etc
/hotplug.d
/firewall
/50-miniupnpd
9 local extiface intiface upload download logging secure enabled natpmp
10 local extip port usesysuptime conffile
12 config_get extiface config external_iface
13 config_get intiface config internal_iface
14 config_get extip config external_ip
15 config_get port config port
5000
16 config_get upload config upload
17 config_get download config download
18 config_get_bool logging config log_output
0
19 config_get_bool secure config secure_mode
0
20 config_get_bool natpmp config enable_natpmp
0
21 config_get_bool enabled config enabled
0
22 config_get_bool usesysuptime config use_system_uptime
1
23 config_get conffile config config_file
29 config_get ifname
${extiface:-wan} ifname
31 if [ -n "$ifname" ]; then
32 local args
="-i $ifname"
36 append args
"-o $extip"
38 for iface
in ${intiface:-lan}; do
40 config_get ipaddr
"$iface" ipaddr
41 [ -n "$ipaddr" ] && append args
"-a $ipaddr"
44 [ "$port" != "auto" ] && \
45 append args
"-p $port"
47 [ "$usesysuptime" -eq 1 ] && \
50 [ -n "$upload" -a -n "$download" ] && \
51 append args
"-B $(($download * 1024 * 8)) $(($upload * 1024 * 8))"
53 [ "$secure" -gt 0 ] && \
56 [ "$natpmp" -gt 0 ] && \
59 [ -n "$conffile" ] && \
60 append args
"-f $conffile"
65 config_get zone core
"${extiface:-wan}_zone"
67 miniupnpd_add_rules
"$zone" "${extiface:-wan}" "$ifname"
69 if [ "$logging" = "1" ]; then
70 [ "$enabled" -gt 0 ] && eval start-stop-daemon
-S -x miniupnpd
-- $args -d | logger
-t miniupnpd
&
72 [ "$enabled" -gt 0 ] && eval start-stop-daemon
-S -x miniupnpd
-- $args 2>/dev
/null
75 logger
-t "upnp daemon" "external interface not found, not starting"
80 start-stop-daemon
-K -q -x miniupnpd
-p /var
/run
/miniupnpd.pid
81 rm -f /var
/run
/miniupnpd.pid
83 type miniupnpd_remove_rules
>/dev
/null
2>/dev
/null || \
84 ACTION
=- .
/etc
/hotplug.d
/firewall
/50-miniupnpd
86 miniupnpd_remove_rules
88 iptables
-t nat
-F MINIUPNPD
2>/dev
/null
89 iptables
-t nat
-X MINIUPNPD
2>/dev
/null
90 iptables
-t filter
-F MINIUPNPD
2>/dev
/null
91 iptables
-t filter
-X MINIUPNPD
2>/dev
/null