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 serial_number model_number
11 local uuid notify_interval presentation_url
13 config_get extiface config external_iface
14 config_get intiface config internal_iface
15 config_get extip config external_ip
16 config_get port config port 5000
17 config_get upload config upload
18 config_get download config download
19 config_get_bool logging config log_output 0
20 config_get_bool secure config secure_mode 0
21 config_get_bool natpmp config enable_natpmp 0
22 config_get_bool enabled config enabled 0
23 config_get_bool usesysuptime config use_system_uptime 1
24 config_get conffile config config_file
25 config_get serial_number config serial_number
26 config_get model_number config model_number
27 config_get uuid config uuid
28 config_get notify_interval config notify_interval
29 config_get presentation_url config presentation_url
35 config_get ifname ${extiface:-wan} ifname
37 if [ -n "$ifname" ]; then
38 local args="-i $ifname"
42 append args "-o $extip"
44 for iface in ${intiface:-lan}; do
46 config_get ipaddr "$iface" ipaddr
47 [ -n "$ipaddr" ] && append args "-a $ipaddr"
50 [ "$port" != "auto" ] && \
51 append args "-p $port"
53 [ "$usesysuptime" -eq 1 ] && \
56 [ -n "$upload" -a -n "$download" ] && \
57 append args "-B $(($download * 1024 * 8)) $(($upload * 1024 * 8))"
59 [ "$secure" -gt 0 ] && \
62 [ "$natpmp" -gt 0 ] && \
65 [ -n "$conffile" ] && \
66 append args "-f $conffile"
68 [ -n "${serial_number}" ] && \
69 append args "-s ${serial_number}"
71 [ -n "${model_number}" ] && \
72 append args "-m ${model_number}"
75 uuid="$(cat /proc/sys/kernel/random/uuid)"
76 uci set upnpd.config.uuid=$uuid
80 [ "$uuid" = "nocli" ] || \
81 append args "-u $uuid"
83 [ -n "${notify_interval}" ] && \
84 append args "-t ${notify_interval}"
86 [ -n "${presentation_url}" ] && \
87 append args "-w \"${presentation_url}\""
91 config_get zone core "${extiface:-wan}_zone"
93 miniupnpd_add_rules "$zone" "${extiface:-wan}" "$ifname"
95 if [ "$logging" = "1" ]; then
96 [ "$enabled" -gt 0 ] && eval start-stop-daemon -S -x miniupnpd -- $args -d | logger -t miniupnpd &
98 [ "$enabled" -gt 0 ] && eval start-stop-daemon -S -x miniupnpd -- $args 2>/dev/null
101 logger -t "upnp daemon" "external interface not found, not starting"
106 start-stop-daemon -K -q -x miniupnpd -p /var/run/miniupnpd.pid
107 rm -f /var/run/miniupnpd.pid
109 type miniupnpd_remove_rules >/dev/null 2>/dev/null || \
110 ACTION=- . /etc/hotplug.d/firewall/50-miniupnpd
112 miniupnpd_remove_rules
114 iptables -t nat -F MINIUPNPD 2>/dev/null
115 iptables -t nat -X MINIUPNPD 2>/dev/null
116 iptables -t filter -F MINIUPNPD 2>/dev/null
117 iptables -t filter -X MINIUPNPD 2>/dev/null