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
11 config_get extiface config external_iface
12 config_get intiface config internal_iface
13 config_get upload config upload
14 config_get download config download
15 config_get_bool logging config log_output 0
16 config_get_bool secure config secure_mode 0
17 config_get_bool natpmp config enable_natpmp 0
18 config_get_bool enabled config enabled 0
24 config_get ifname ${extiface:-wan} ifname
26 if [ -n "$ifname" ]; then
27 local args="-i $ifname"
30 for iface in ${intiface:-lan}; do
32 config_get ipaddr "$iface" ipaddr
33 [ -n "$ipaddr" ] && append args "-a $ipaddr"
36 append args "-p 5000 -U"
38 [ -n "$upload" -a -n "$download" ] && \
39 append args "-B $(($download * 1024 * 8)) $(($upload * 1024 * 8))"
41 [ "$secure" -gt 0 ] && \
44 [ "$natpmp" -gt 0 ] && \
50 config_get zone core "${extiface:-wan}_zone"
52 miniupnpd_add_rules "$zone" "${extiface:-wan}" "$ifname"
54 if [ "$logging" = "1" ]; then
55 [ "$enabled" -gt 0 ] && eval start-stop-daemon -S -x miniupnpd -- $args -d | logger -t miniupnpd &
57 [ "$enabled" -gt 0 ] && eval start-stop-daemon -S -x miniupnpd -- $args 2>/dev/null
60 logger -t "upnp daemon" "external interface not found, not starting"
65 start-stop-daemon -K -q -x miniupnpd -p /var/run/miniupnpd.pid
66 rm -f /var/run/miniupnpd.pid
68 type miniupnpd_remove_rules >/dev/null 2>/dev/null || \
69 ACTION=- . /etc/hotplug.d/firewall/50-miniupnpd
71 miniupnpd_remove_rules
73 iptables -t nat -F MINIUPNPD 2>/dev/null
74 iptables -t nat -X MINIUPNPD 2>/dev/null
75 iptables -t filter -F MINIUPNPD 2>/dev/null
76 iptables -t filter -X MINIUPNPD 2>/dev/null