Version 0.3.0 from FTP
[asterisk/asterisk.git] / contrib / init.d / rc.redhat.asterisk
1 #!/bin/sh
2 #
3 # asterisk    This shell script takes care of starting and stopping Asterisk.
4 #               
5 #
6 # chkconfig: 2345 60 60
7 # description: Asterisk is the Linux based PBX
8 # processname: asterisk
9
10 # Source function library.
11 . /etc/rc.d/init.d/functions
12
13 [ -f /usr/sbin/asterisk ] || exit 0
14
15 RETVAL=0
16
17 # See how we were called.
18 case "$1" in
19   start)
20         # Start daemons.
21         echo -n "Starting asterisk: "
22         daemon safe_asterisk
23         RETVAL=$?
24         echo
25         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/asterisk
26         ;;
27   stop)
28         # Stop daemons.
29         echo -n "Shutting down asterisk: "
30         killproc asterisk
31         RETVAL=$?
32         echo
33         [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/asterisk
34         ;;
35   status)
36         status asterisk
37         RETVAL=$?
38         ;;
39   restart|reload)
40         $0 stop
41         $0 start
42         RETVAL=$?
43         ;;
44   *)
45         echo "Usage: asterisk {start|stop|restart|reload|status}"
46         exit 1
47 esac
48
49 exit $RETVAL