Original linux-igd sources from CVS repo:
[igd2-for-linux:wanipconnection2.git] / linuxigd2 / etc / upnpd.rc
1 #!/bin/bash
2 #
3 #       /etc/rc.d/init.d/upnpd
4 #
5 # Starts the upnpd daemon
6 #
7 # chkconfig: 345 95 5
8 # description: Internet Gateway Device
9 # processname: upnpd
10
11 # Source function library.
12 . /etc/init.d/functions
13
14 # defaults
15 ALLOW_MULTICAST=no
16
17 # Source configuration
18 . /etc/sysconfig/upnpd
19
20 UPNPD=/usr/sbin/upnpd
21
22 test -x "$UPNPD" || exit 0
23
24 RETVAL=0
25
26 #
27 #       See how we were called.
28 #
29
30 prog="upnpd"
31
32 start() {
33         # Check if upnpd is already running
34         if [ ! -f /var/lock/subsys/upnpd ]; then
35             echo -n $"Starting $prog: "
36             [ "$ALLOW_MULTICAST" != "no" ] && route add -net 239.0.0.0 netmask 255.0.0.0 $INTIFACE
37             daemon "$UPNPD" $EXTIFACE $INTIFACE
38             RETVAL=$?
39             [ $RETVAL -eq 0 ] && touch /var/lock/subsys/upnpd
40             echo
41         fi
42         return $RETVAL
43 }
44
45 stop() {
46         echo -n $"Stopping $prog: "
47         killproc "$UPNPD"
48         RETVAL=$?
49         [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/upnpd
50         [ "$ALLOW_MULTICAST" != "no" ] && route del -net 239.0.0.0 netmask 255.0.0.0 $INTIFACE
51         echo
52         return $RETVAL
53 }
54
55
56 restart() {
57         stop
58         sleep 10
59         start
60 }       
61
62 reload() {
63         restart
64 }       
65
66 status_at() {
67         status "$UPNPD"
68 }
69
70 case "$1" in
71 start)
72         start
73         ;;
74 stop)
75         stop
76         ;;
77 reload|restart)
78         restart
79         ;;
80 condrestart)
81         if [ -f /var/lock/subsys/upnpd ]; then
82             restart
83         fi
84         ;;
85 status)
86         status_at
87         ;;
88 *)
89         echo $"Usage: $0 {start|stop|restart|condrestart|status}"
90         exit 1
91 esac
92
93 exit $?