[package] fix ucmb compilation (#4711)
[openwrt/svn-archive/archive.git] / net / miniupnpd / files / miniupnpd.init
1 #!/bin/sh /etc/rc.common
2 START=95
3
4 include /lib/miniupnpd
5
6 boot() {
7 # On boot, there's a race condition with hotplug,
8 # therfore do nothing here
9 return
10 }
11
12 start() {
13 local extif
14 local intif
15 local extiface
16 local upload
17 local download
18 local logging
19 local secure
20
21 config_load "upnpd"
22 config_get extif config external_iface
23 config_get intif config internal_iface
24 config_get upload config upload
25 config_get download config download
26 config_get_bool logging config log_output 0
27 config_get_bool secure config secure_mode 0
28
29 config_load "network"
30 config_get extiface ${extif:-wan} ifname
31
32 if [ -n "$extiface" ]; then
33 upnp_firewall_start
34
35 local args="-i $extiface"
36
37 for iface in ${intif:-lan}; do
38 local ipaddr
39 config_get ipaddr "$iface" ipaddr
40 [ -n "$ipaddr" ] && append args "-a $ipaddr"
41 done
42
43 append args "-p 5000 -U"
44
45 [ -n "$upload" -a -n "$download" ] && \
46 append args "-B $(($download * 1024 * 8)) $(($upload * 1024 * 8))"
47
48 [ "$secure" -gt 0 ] && \
49 append args "-S"
50
51 if [ "$logging" = "1" ]; then
52 eval start-stop-daemon -S -x miniupnpd -- $args -d | logger -t miniupnpd &
53 else
54 eval start-stop-daemon -S -x miniupnpd -- $args 2>/dev/null
55 fi
56 else
57 logger -t "upnp daemon" "external interface not found, not starting"
58 fi
59 }
60
61 stop() {
62 start-stop-daemon -K -q -x miniupnpd -p /var/run/miniupnpd.pid
63 upnp_firewall_stop
64 }