mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-11-03 04:16:43 +00:00 
			
		
		
		
	https://origsvn.digium.com/svn/asterisk/trunk ................ r136191 | tilghman | 2008-08-06 15:15:34 -0500 (Wed, 06 Aug 2008) | 12 lines Merged revisions 136190 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r136190 | tilghman | 2008-08-06 15:14:54 -0500 (Wed, 06 Aug 2008) | 4 lines -C option takes a filename, not a directory path. (closes issue #13007) Reported by: klaus3000 ........ ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@136192 65c4cc65-6c06-0410-ace0-fbb531ad65f3
		
			
				
	
	
		
			145 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			145 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/bin/sh
 | 
						|
# $Id$
 | 
						|
#
 | 
						|
# asterisk    Starts, Stops and Reloads Asterisk.
 | 
						|
#
 | 
						|
# chkconfig: 2345 90 60
 | 
						|
# description: Asterisk PBX and telephony daemon.
 | 
						|
# processname: asterisk
 | 
						|
# pidfile: /var/run/asterisk.pid
 | 
						|
#
 | 
						|
# 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
 | 
						|
#
 | 
						|
# 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' 
 | 
						|
 | 
						|
# 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"
 | 
						|
 | 
						|
# Source function library.
 | 
						|
. /etc/rc.d/init.d/functions
 | 
						|
 | 
						|
if ! [ -x $AST_SBIN/asterisk ] ; then
 | 
						|
	echo "ERROR: $AST_SBIN/asterisk not found"
 | 
						|
	exit 0
 | 
						|
fi
 | 
						|
 | 
						|
if ! [ -d $AST_CONFIG ] ; then
 | 
						|
	echo "ERROR: $AST_CONFIG directory not found"
 | 
						|
	exit 0
 | 
						|
fi
 | 
						|
 | 
						|
# Uncomment this ONLY if you know what you are doing.
 | 
						|
# export LD_ASSUME_KERNEL=2.4.1
 | 
						|
 | 
						|
# Full path to asterisk binary
 | 
						|
DAEMON=$AST_SBIN/asterisk
 | 
						|
 | 
						|
# Full path to safe_asterisk script
 | 
						|
SAFE_ASTERISK=$AST_SBIN/safe_asterisk
 | 
						|
 | 
						|
# Allow configuration overrides in /etc/sysconfig/asterisk
 | 
						|
CONFIG0=`readlink $0`
 | 
						|
if [ "$CONFIG0" = "" ]; then
 | 
						|
	CONFIGFILE=/etc/sysconfig/`basename $0`
 | 
						|
else
 | 
						|
	CONFIGFILE=/etc/sysconfig/`basename $CONFIG0`
 | 
						|
fi
 | 
						|
[ -x $CONFIGFILE ] && . $CONFIGFILE
 | 
						|
 | 
						|
RETVAL=0
 | 
						|
 | 
						|
start() {
 | 
						|
	# Check if Asterisk is already running.  If it is, then bug out, because
 | 
						|
	# starting safe_asterisk when Asterisk is running is very bad.
 | 
						|
	VERSION=`${AST_SBIN}/asterisk -rx 'core show version'`
 | 
						|
	if [ "`echo $VERSION | cut -c 1-8`" = "Asterisk" ]; then
 | 
						|
		echo "Asterisk is already running."
 | 
						|
		exit 1
 | 
						|
	fi
 | 
						|
 | 
						|
	# 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
 | 
						|
		ASTARGS="$ASTARGS -G $AST_GROUP"
 | 
						|
	fi
 | 
						|
	if [ $AST_CONFIG ]; then
 | 
						|
		ASTARGS="$ASTARGS -C $AST_CONFIG/asterisk.conf"
 | 
						|
	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
 | 
						|
}
 | 
						|
 | 
						|
# See how we were called.
 | 
						|
case "$1" in
 | 
						|
  start)
 | 
						|
	start
 | 
						|
	;;
 | 
						|
  stop)
 | 
						|
	stop
 | 
						|
	;;
 | 
						|
  restart)
 | 
						|
	restart
 | 
						|
	;;
 | 
						|
  reload)
 | 
						|
	reload
 | 
						|
	;;
 | 
						|
  condrestart)
 | 
						|
	[ -f /var/lock/subsys/asterisk ] && restart || :
 | 
						|
	;;
 | 
						|
  status)
 | 
						|
	status asterisk
 | 
						|
	;;
 | 
						|
  *)
 | 
						|
	echo "Usage: asterisk {start|stop|restart|reload|condrestart|status}"
 | 
						|
	exit 1
 | 
						|
esac
 | 
						|
 | 
						|
exit $?
 |