2 # $Id: asterisk,v 1.3 2005/11/17 22:30:01 Gregory Boehnlein <damin@nacs.net>
4 # asterisk Starts, Stops and Reloads Asterisk.
6 # chkconfig: 2345 40 60
7 # description: Asterisk PBX and telephony daemon.
8 # processname: asterisk
9 # pidfile: /var/run/asterisk.pid
11 # Thu Nov 17 2005 Gregory Boehnlein <damin@nacs.net>
12 # - Updated Version to 1.3
13 # - Reversed behavior of LD_ASSUME_KERNEL=2.4.1
14 # - Added detailed failure messages
16 # Sun Jul 18 2004 Gregory Boehnlein <damin@nacs.net>
17 # - Updated Version to 1.2
18 # - Added test for safe_asterisk
19 # - Verified SIGTERM issued by "killproc" ensures "stop gracefully"
20 # - Added support for -U and -G command line options
21 # - Modified "reload" to call asterisk -rx 'reload'
23 # Source function library.
24 . /etc/rc.d/init.d/functions
26 if ! [ -x /usr/sbin/asterisk ] ; then
27 echo "ERROR: /usr/sbin/asterisk not found"
31 if ! [ -d /etc/asterisk ] ; then
32 echo "ERROR: /etc/asterisk directory not found"
36 # Uncomment this ONLY if you know what you are doing.
37 # export LD_ASSUME_KERNEL=2.4.1
39 # Full path to asterisk binary
40 DAEMON=/usr/sbin/asterisk
42 # Full path to safe_asterisk script
43 SAFE_ASTERISK=/usr/sbin/safe_asterisk
45 # Uncomment the following and set them to the user/groups that you
46 # want to run Asterisk as. NOTE: this requires substantial work to
47 # be sure that Asterisk's environment has permission to write the
48 # files required for its operation, including logs, its comm
49 # socket, the asterisk database, etc.
57 echo -n $"Starting asterisk: "
58 if [ -f $SAFE_ASTERISK ] ; then
61 if [ $AST_USER ] ; then
62 ASTARGS="-U $AST_USER"
64 if [ $AST_GROUP ] ; then
65 ASTARGS="`echo $ASTARGS` -G $AST_GROUP"
67 daemon $DAEMON $ASTARGS
69 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/asterisk
76 echo -n $"Shutting down asterisk: "
79 [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/asterisk
90 $DAEMON -rx 'reload' > /dev/null 2> /dev/null
93 # See how we were called.
108 [ -f /var/lock/subsys/asterisk ] && restart || :
114 echo "Usage: asterisk {start|stop|restart|reload|condrestart|status}"