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
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 enabled config enabled 0
23 config_get ifname ${extiface:-wan} ifname
25 if [ -n "$ifname" ]; then
26 local args="-i $ifname"
29 for iface in ${intiface:-lan}; do
31 config_get ipaddr "$iface" ipaddr
32 [ -n "$ipaddr" ] && append args "-a $ipaddr"
35 append args "-p 5000 -U"
37 [ -n "$upload" -a -n "$download" ] && \
38 append args "-B $(($download * 1024 * 8)) $(($upload * 1024 * 8))"
40 [ "$secure" -gt 0 ] && \
43 if [ "$logging" = "1" ]; then
44 [ "$enabled" -gt 0 ] && eval start-stop-daemon -S -x miniupnpd -- $args -d | logger -t miniupnpd &
46 [ "$enabled" -gt 0 ] && eval start-stop-daemon -S -x miniupnpd -- $args 2>/dev/null
52 config_get zone core "${extiface:-wan}_zone"
54 miniupnpd_add_rules "$zone" "${extiface:-wan}" "$ifname"
56 logger -t "upnp daemon" "external interface not found, not starting"
61 start-stop-daemon -K -q -x miniupnpd -p /var/run/miniupnpd.pid
62 rm -f /var/run/miniupnpd.pid
64 type miniupnpd_remove_rules >/dev/null 2>/dev/null || \
65 ACTION=- . /etc/hotplug.d/firewall/50-miniupnpd
67 miniupnpd_remove_rules
69 iptables -t nat -F MINIUPNPD 2>/dev/null
70 iptables -t nat -X MINIUPNPD 2>/dev/null
71 iptables -t filter -F MINIUPNPD 2>/dev/null
72 iptables -t filter -X MINIUPNPD 2>/dev/null