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