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.
62 # Allow configuration overrides in /etc/sysconfig/asterisk
64 if [ "$CONFIG0" = "" ]; then
65 CONFIGFILE=/etc/sysconfig/`basename $0`
67 CONFIGFILE=/etc/sysconfig/`basename $CONFIG0`
69 [ -r $CONFIGFILE ] && . $CONFIGFILE
76 # Check if Asterisk is already running. If it is, then bug out, because
77 # starting Asterisk when Asterisk is already running is very bad.
78 VERSION=`/usr/sbin/asterisk -rx 'core show version'`
79 if [ "`echo $VERSION | cut -c 1-8`" = "Asterisk" ]; then
80 echo "Asterisk is already running. $0 will exit now."
84 echo -n $"Starting asterisk: "
85 if [ -f $SAFE_ASTERISK ] ; then
88 if [ $AST_USER ] ; then
89 ASTARGS="-U $AST_USER"
91 if [ $AST_GROUP ] ; then
92 ASTARGS="`echo $ASTARGS` -G $AST_GROUP"
95 ASTARGS="$ASTARGS -C $ALTCONF"
97 if [ "x$COREDUMP" = "xyes" ]; then
100 if [ "0$MAXLOAD" -gt "0" ]; then
101 ASTARGS="$ASTARGS -L $MAXLOAD"
103 if [ "0$MAXCALLS" -gt "0" ]; then
104 ASTARGS="$ASTARGS -M $MAXCALLS"
106 if [ "$VERBOSITY" -gt "0" ]; then
107 for i in `seq 1 $VERBOSITY`; do
108 ASTARGS="$ASTARGS -v"
111 if [ "x$INTERNALTIMING" = "xyes" ]; then
112 ASTARGS="$ASTARGS -I"
114 if [ "x$TEMPRECORDINGLOCATION" = "xyes" -o "x$TMPRECORDINGLOCATION" = "xyes" ]; then
115 ASTARGS="$ASTARGS -t"
117 if [ "x$COLOR" = "xyes" ]; then
119 sh -c "$DAEMON $ASTARGS -c" >/dev/null </dev/null 2>&1 &
124 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/asterisk
131 echo -n $"Shutting down asterisk: "
134 [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/asterisk
145 $DAEMON -rx 'module reload' > /dev/null 2> /dev/null
148 # See how we were called.
163 [ -f /var/lock/subsys/asterisk ] && restart || :
169 echo "Usage: asterisk {start|stop|restart|reload|condrestart|status}"