S99upnpd
1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/sh
NAME=upnpd
PIDFILE=/var/run/$NAME.pid
DAEMON=/usr/sbin/$NAME
CFGFILE=/etc/default/$NAME
LAN=eth0
WAN=eth0
# For the UPnP library to function correctly, networking must be configured
# properly for multicasting as described in
# https://sourceforge.net/p/pupnp/code/ci/master/tree/README.
# Without this addition, device advertisements and control point searches will
# not function.
# However, the route has to be configured once for all UPnP applications
# (igd2-for-linux, ushare, ...) so do not manage UPnP route by default
MANAGE_UPNP_MULTICAST_ROUTE_ON_LAN=0
# Read configuration variable file if it is present
if [ -f $CFGFILE ]; then
. $CFGFILE
fi
DAEMON_ARGS="-f $WAN $LAN"
start() {
if [ $MANAGE_UPNP_MULTICAST_ROUTE_ON_LAN != 0 ]; then
printf "Add UPnP multicast route on $LAN\n"
route add -net 239.0.0.0 netmask 255.0.0.0 $LAN
fi
printf "Starting $NAME: "
start-stop-daemon -S -q -m -b -p $PIDFILE --exec $DAEMON -- $DAEMON_ARGS
[ $? = 0 ] && echo "OK" || echo "FAIL"
}
stop() {
printf "Stopping $NAME: "
start-stop-daemon -K -q -p $PIDFILE
[ $? = 0 ] && echo "OK" || echo "FAIL"
if [ $MANAGE_UPNP_MULTICAST_ROUTE_ON_LAN != 0 ]; then
printf "Remove UPnP multicast route on $LAN\n"
route del -net 239.0.0.0 netmask 255.0.0.0 $LAN
fi
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac
exit $?