S99upnpd 1.4 KB

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