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'
25 # Required-Start: +dahdi $network $named
28 # Default-Stop: 0 1 2 4 6
29 # Description: dahdi - dahdi modules for Asterisk
32 # Source function library.
33 . /lib/lsb/init-functions
35 if ! [ -x /usr/sbin/asterisk ] ; then
36 echo "ERROR: /usr/sbin/asterisk not found"
40 if ! [ -d /etc/asterisk ] ; then
41 echo "ERROR: /etc/asterisk directory not found"
45 # Uncomment this ONLY if you know what you are doing.
46 # export LD_ASSUME_KERNEL=2.4.1
48 # Full path to asterisk binary
49 DAEMON=/usr/sbin/asterisk
51 # Full path to safe_asterisk script
52 SAFE_ASTERISK=/usr/sbin/safe_asterisk
54 # Uncomment the following and set them to the user/groups that you
55 # want to run Asterisk as. NOTE: this requires substantial work to
56 # be sure that Asterisk's environment has permission to write the
57 # files required for its operation, including logs, its comm
58 # socket, the asterisk database, etc.
67 # Check if Asterisk is already running. If it is, then bug out, because
68 # starting Asterisk when Asterisk is already running is very bad.
69 VERSION=`/usr/sbin/asterisk -rx 'core show version'`
70 if [ "`echo $VERSION | cut -c 1-8`" = "Asterisk" ]; then
71 echo "Asterisk is already running. $0 will exit now."
75 echo -n $"Starting asterisk: "
76 if [ -f $SAFE_ASTERISK ] ; then
79 if [ $AST_USER ] ; then
80 ASTARGS="-U $AST_USER"
82 if [ $AST_GROUP ] ; then
83 ASTARGS="`echo $ASTARGS` -G $AST_GROUP"
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 'module 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}"