updated on Sat Jan 14 12:12:45 UTC 2012
[aur-mirror.git] / linuxigd / upnpd.rc
blobfb1fc62e39193da82993a64308beb4ea148ff7bb
1 #!/bin/bash
3 # Source application-specific settings.
4 [ -f /etc/conf.d/upnpd ] && . /etc/conf.d/upnpd
6 # Set defaults if settings are missing.
7 [ -z "$INTERNAL_INTERFACE" ] && INTERNAL_INTERFACE="eth0"
8 [ -z "$EXTERNAL_INTERFACE" ] && EXTERNAL_INTERFACE="ppp0"
9 [ -z "$ALLOW_MULTICAST" ] && ALLOW_MULTICAST="yes"
11 . /etc/rc.conf
12 . /etc/rc.d/functions
14 PID=`pidof -o %PPID /usr/sbin/upnpd`
15 case "$1" in
16 start)
17 stat_busy "Starting UPnP Daemon"
18 if [ -z "$PID" ]; then
19 if [ "$ALLOW_MULTICAST" = "yes" ]; then
20 /sbin/route add -net 239.0.0.0 netmask 255.0.0.0 $INTERNAL_INTERFACE &> /dev/null
22 /usr/sbin/upnpd $EXTERNAL_INTERFACE $INTERNAL_INTERFACE
24 if [ ! -z "$PID" -o $? -gt 0 ]; then
25 stat_fail
26 else
27 PID=`pidof -o %PPID /usr/sbin/upnpd`
28 echo $PID > /var/run/upnpd.pid
29 add_daemon upnpd
30 stat_done
33 stop)
34 stat_busy "Stoping UPnP Daemon"
35 if [ ! -z "$PID" ]; then
36 if [ "$ALLOW_MULTICAST" = "yes" ]; then
37 /sbin/route del -net 239.0.0.0 netmask 255.0.0.0 $INTERNAL_INTERFACE &> /dev/null
39 kill $PID &> /dev/null
41 if [ $? -gt 0 ]; then
42 stat_fail
43 else
44 rm_daemon upnpd
45 stat_done
48 restart)
49 $0 stop
50 sleep 1
51 $0 start
54 echo "usage: $0 {start|stop|restart}"
55 esac