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 # Use this option to specify a different configuration directory
24 #AST_CONFIG=/etc/asterisk
26 # Installation directory
29 # Uncomment the following and set them to the user/groups that you
30 # want to run Asterisk as. NOTE: this requires substantial work to
31 # be sure that Asterisk's environment has permission to write the
32 # files required for its operation, including logs, its comm
33 # socket, the asterisk database, etc.
37 # Source function library.
38 . /etc/rc.d/init.d/functions
40 if ! [ -x $AST_SBIN/asterisk ] ; then
41 echo "ERROR: /usr/sbin/asterisk not found"
45 if ! [ -d $AST_CONFIG ] ; then
46 echo "ERROR: $AST_CONFIG directory not found"
50 # Uncomment this ONLY if you know what you are doing.
51 # export LD_ASSUME_KERNEL=2.4.1
53 # Full path to asterisk binary
54 DAEMON=$AST_SBIN/asterisk
56 # Full path to safe_asterisk script
57 SAFE_ASTERISK=$AST_SBIN/safe_asterisk
59 # Allow configuration overrides in /etc/sysconfig/asterisk
61 if [ "$CONFIG0" = "" ]; then
62 CONFIGFILE=/etc/sysconfig/`basename $0`
64 CONFIGFILE=/etc/sysconfig/`basename $CONFIG0`
66 [ -x $CONFIGFILE ] && . $CONFIGFILE
72 echo -n $"Starting asterisk: "
73 if [ -f $SAFE_ASTERISK ] ; then
76 if [ $AST_USER ] ; then
77 ASTARGS="-U $AST_USER"
79 if [ $AST_GROUP ] ; then
80 ASTARGS="$ASTARGS -G $AST_GROUP"
82 if [ $AST_CONFIG ]; then
83 ASTARGS="$ASTARGS -C $AST_CONFIG"
85 daemon $DAEMON $ASTARGS
87 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/asterisk
94 echo -n $"Shutting down asterisk: "
97 [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/asterisk
108 $DAEMON -rx 'reload' > /dev/null 2> /dev/null
111 # See how we were called.
126 [ -f /var/lock/subsys/asterisk ] && restart || :
132 echo "Usage: asterisk {start|stop|restart|reload|condrestart|status}"