2 # $Id: asterisk,v 1.3 2005/11/17 22:30:01 Gregory Boehnlein <damin@nacs.net>
4 # asterisk start the asterisk PBX
6 # Thu Nov 17 2005 Gregory Boehnlein <damin@nacs.net>
7 # - Updated Version to 1.3
8 # - Reversed behavior of LD_ASSUME_KERNEL=2.4.1
9 # - Added detailed failure messages
11 # Sun Jul 18 2004 Gregory Boehnlein <damin@nacs.net>
12 # - Updated Version to 1.2
13 # - Added test for safe_asterisk
14 # - Changed "stop gracefully" to "stop now"
15 # - Added support for -U and -G command line options
16 # - Modified "reload" to call asterisk -rx 'reload'
18 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
21 # Full path to asterisk binary
22 DAEMON=/usr/sbin/asterisk
24 # Full path to safe_asterisk script
25 SAFE_ASTERISK=/usr/sbin/safe_asterisk
27 # Uncomment this ONLY if you know what you are doing.
28 # export LD_ASSUME_KERNEL=2.4.1
30 # Uncomment the following and set them to the user/groups that you
31 # want to run Asterisk as. NOTE: this requires substantial work to
32 # be sure that Asterisk's environment has permission to write the
33 # files required for its operation, including logs, its comm
34 # socket, the asterisk database, etc.
38 if ! [ -x $DAEMON ] ; then
39 echo "ERROR: /usr/sbin/asterisk not found"
43 if ! [ -d /etc/asterisk ] ; then
44 echo "ERROR: /etc/asterisk directory not found"
52 echo -n "Starting $DESC: "
53 if [ -f $SAFE_ASTERISK ] ; then
56 if [ $AST_USER ] ; then
57 ASTARGS="-U $AST_USER"
59 if [ $AST_GROUP ] ; then
60 ASTARGS="`echo $ASTARGS` -G $AST_GROUP"
62 start-stop-daemon --start --exec $DAEMON -- $ASTARGS
66 echo -n "Stopping $DESC: "
67 $DAEMON -rx 'stop now' > /dev/null 2> /dev/null && echo -n "$NAME"
72 echo "Reloading $DESC configuration files."
73 $DAEMON -rx 'reload' > /dev/null 2> /dev/null
76 $DAEMON -rx 'restart gracefully' > /dev/null 2> /dev/null && echo -n "$NAME"
80 echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2