2002-06-19 02:35:40 +00:00
|
|
|
#!/bin/sh
|
2007-06-04 17:12:35 +00:00
|
|
|
# $Id$
|
2002-06-19 02:35:40 +00:00
|
|
|
#
|
2004-07-19 01:48:52 +00:00
|
|
|
# asterisk Starts, Stops and Reloads Asterisk.
|
2002-06-19 02:35:40 +00:00
|
|
|
#
|
2006-10-31 06:31:34 +00:00
|
|
|
# chkconfig: 2345 90 60
|
2004-07-19 01:48:52 +00:00
|
|
|
# description: Asterisk PBX and telephony daemon.
|
2002-06-19 02:35:40 +00:00
|
|
|
# processname: asterisk
|
2004-07-19 01:48:52 +00:00
|
|
|
# pidfile: /var/run/asterisk.pid
|
|
|
|
#
|
2005-11-30 21:22:38 +00:00
|
|
|
# Thu Nov 17 2005 Gregory Boehnlein <damin@nacs.net>
|
|
|
|
# - Updated Version to 1.3
|
|
|
|
# - Reversed behavior of LD_ASSUME_KERNEL=2.4.1
|
|
|
|
# - Added detailed failure messages
|
|
|
|
#
|
2004-07-19 01:48:52 +00:00
|
|
|
# Sun Jul 18 2004 Gregory Boehnlein <damin@nacs.net>
|
|
|
|
# - Updated Version to 1.2
|
|
|
|
# - Added test for safe_asterisk
|
|
|
|
# - Verified SIGTERM issued by "killproc" ensures "stop gracefully"
|
|
|
|
# - Added support for -U and -G command line options
|
|
|
|
# - Modified "reload" to call asterisk -rx 'reload'
|
2002-06-19 02:35:40 +00:00
|
|
|
|
2006-03-25 05:10:07 +00:00
|
|
|
# Use this option to specify a different configuration directory
|
|
|
|
#AST_CONFIG=/etc/asterisk
|
|
|
|
|
|
|
|
# Installation directory
|
|
|
|
AST_SBIN=/usr/sbin
|
|
|
|
|
|
|
|
# Uncomment the following and set them to the user/groups that you
|
|
|
|
# want to run Asterisk as. NOTE: this requires substantial work to
|
|
|
|
# be sure that Asterisk's environment has permission to write the
|
|
|
|
# files required for its operation, including logs, its comm
|
|
|
|
# socket, the asterisk database, etc.
|
|
|
|
#AST_USER="asterisk"
|
|
|
|
#AST_GROUP="asterisk"
|
|
|
|
|
2002-06-19 02:35:40 +00:00
|
|
|
# Source function library.
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
|
2006-03-25 05:10:07 +00:00
|
|
|
if ! [ -x $AST_SBIN/asterisk ] ; then
|
2006-10-02 19:43:00 +00:00
|
|
|
echo "ERROR: $AST_SBIN/asterisk not found"
|
2005-11-30 21:22:38 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2006-03-25 05:10:07 +00:00
|
|
|
if ! [ -d $AST_CONFIG ] ; then
|
2006-03-28 17:49:39 +00:00
|
|
|
echo "ERROR: $AST_CONFIG directory not found"
|
2005-11-30 21:22:38 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
2004-07-19 01:48:52 +00:00
|
|
|
|
2005-11-30 21:22:38 +00:00
|
|
|
# Uncomment this ONLY if you know what you are doing.
|
|
|
|
# export LD_ASSUME_KERNEL=2.4.1
|
2004-07-19 01:48:52 +00:00
|
|
|
|
|
|
|
# Full path to asterisk binary
|
2006-03-25 05:10:07 +00:00
|
|
|
DAEMON=$AST_SBIN/asterisk
|
2004-07-19 01:48:52 +00:00
|
|
|
|
|
|
|
# Full path to safe_asterisk script
|
2006-03-25 05:10:07 +00:00
|
|
|
SAFE_ASTERISK=$AST_SBIN/safe_asterisk
|
2004-07-19 01:48:52 +00:00
|
|
|
|
2006-03-25 05:10:07 +00:00
|
|
|
# Allow configuration overrides in /etc/sysconfig/asterisk
|
|
|
|
CONFIG0=`readlink $0`
|
2006-03-28 17:49:39 +00:00
|
|
|
if [ "$CONFIG0" = "" ]; then
|
2006-03-25 05:10:07 +00:00
|
|
|
CONFIGFILE=/etc/sysconfig/`basename $0`
|
|
|
|
else
|
|
|
|
CONFIGFILE=/etc/sysconfig/`basename $CONFIG0`
|
|
|
|
fi
|
|
|
|
[ -x $CONFIGFILE ] && . $CONFIGFILE
|
2002-06-19 02:35:40 +00:00
|
|
|
|
|
|
|
RETVAL=0
|
|
|
|
|
2004-07-19 01:48:52 +00:00
|
|
|
start() {
|
|
|
|
# Start daemons.
|
|
|
|
echo -n $"Starting asterisk: "
|
|
|
|
if [ -f $SAFE_ASTERISK ] ; then
|
|
|
|
DAEMON=$SAFE_ASTERISK
|
|
|
|
fi
|
|
|
|
if [ $AST_USER ] ; then
|
|
|
|
ASTARGS="-U $AST_USER"
|
|
|
|
fi
|
|
|
|
if [ $AST_GROUP ] ; then
|
2006-03-25 05:10:07 +00:00
|
|
|
ASTARGS="$ASTARGS -G $AST_GROUP"
|
|
|
|
fi
|
|
|
|
if [ $AST_CONFIG ]; then
|
|
|
|
ASTARGS="$ASTARGS -C $AST_CONFIG"
|
2004-07-19 01:48:52 +00:00
|
|
|
fi
|
|
|
|
daemon $DAEMON $ASTARGS
|
|
|
|
RETVAL=$?
|
|
|
|
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/asterisk
|
|
|
|
echo
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
# Stop daemons.
|
|
|
|
echo -n $"Shutting down asterisk: "
|
|
|
|
killproc asterisk
|
|
|
|
RETVAL=$?
|
|
|
|
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/asterisk
|
|
|
|
echo
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
restart() {
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
}
|
|
|
|
|
|
|
|
reload() {
|
|
|
|
$DAEMON -rx 'reload' > /dev/null 2> /dev/null
|
|
|
|
}
|
|
|
|
|
2002-06-19 02:35:40 +00:00
|
|
|
# See how we were called.
|
|
|
|
case "$1" in
|
|
|
|
start)
|
2004-07-19 01:48:52 +00:00
|
|
|
start
|
|
|
|
;;
|
2002-06-19 02:35:40 +00:00
|
|
|
stop)
|
2004-07-19 01:48:52 +00:00
|
|
|
stop
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
restart
|
2002-06-19 02:35:40 +00:00
|
|
|
;;
|
2004-04-26 07:06:29 +00:00
|
|
|
reload)
|
2004-07-19 01:48:52 +00:00
|
|
|
reload
|
2004-04-26 07:06:29 +00:00
|
|
|
;;
|
2004-07-19 01:48:52 +00:00
|
|
|
condrestart)
|
|
|
|
[ -f /var/lock/subsys/asterisk ] && restart || :
|
|
|
|
;;
|
|
|
|
status)
|
|
|
|
status asterisk
|
2002-06-19 02:35:40 +00:00
|
|
|
;;
|
|
|
|
*)
|
2004-07-19 01:48:52 +00:00
|
|
|
echo "Usage: asterisk {start|stop|restart|reload|condrestart|status}"
|
|
|
|
exit 1
|
2002-06-19 02:35:40 +00:00
|
|
|
esac
|
|
|
|
|
2004-07-19 01:48:52 +00:00
|
|
|
exit $?
|