298d9641d739a7a09d0f7e2004c73be9429f0cfc
[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   reload)
40         echo -n "Reloading asterisk: "
41         asterisk -r -x reload > /dev/null 2>&1
42         RETVAL=$?
43         [ $RETVAL -eq 0 ] && success || failure
44         echo
45         ;;
46   restart)
47         $0 stop
48         $0 start
49         RETVAL=$?
50         ;;
51   *)
52         echo "Usage: asterisk {start|stop|restart|reload|status}"
53         exit 1
54 esac
55
56 exit $RETVAL