When r376428 was commited to re-order start up sequences to be more tolerant of forking with thread primitives, a few items were changed that caused changes in behavior on some distros. This includes: * Not displaying the splash screen on a remote console. * Displaying an error message on stderr when a remote console cannot connect to a running instance of Asterisk. In the first case, the splash screen was re-added (thanks to Michael L. Young). In the second case, the various init.d scripts were modified to pipe stderr to /dev/null, as the error message is useful - if you execute a remote console or a remote console command execution and it fail, it should tell you. Note that the error message was always present, it just failed to be printed prior to r376428. Much thanks to the folks who quickly reported this problem, provided solutions, and promptly tested the various init.d scripts on a variety of distros. (closes issue ASTERISK-20945) Reported by: Warren Selby Tested by: Michael L. Young, Jamuel Starkey, kaldemar, Danny Nicholas, mjordan patches: asterisk-20945-remote-intro-msg.diff uploaded by elguero (license 5026) ASTERISK-20945-1.8-mjordan.diff uploaded by mjordan (license 6283) ........ Merged revisions 379760 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 379777 from http://svn.asterisk.org/svn/asterisk/branches/10 ........ Merged revisions 379790 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@379791 65c4cc65-6c06-0410-ace0-fbb531ad65f3
144 lines
4.3 KiB
Bash
Executable file
144 lines
4.3 KiB
Bash
Executable file
#! /bin/sh
|
|
# $Id$
|
|
#
|
|
# Mon Jun 04 2007 Iñaki Baz Castillo <ibc@in.ilimit.es>
|
|
# - Eliminated SAFE_ASTERISK since it doesn't work as LSB script (it could require a independent "safe_asterisk" init script).
|
|
# - Load and use the standar "/lib/lsb/init-functions".
|
|
# - Added "--oknodo" to "start-stop-daemon" for compatibility with LSB:
|
|
# http://www.linux-foundation.org/spec/refspecs/LSB_3.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
|
|
#
|
|
# Thu Nov 17 2005 Gregory Boehnlein <damin@nacs.net>
|
|
# - Reversed behavior of LD_ASSUME_KERNEL=2.4.1
|
|
# - Added detailed failure messages
|
|
#
|
|
# Sun Jul 18 2004 Gregory Boehnlein <damin@nacs.net>
|
|
# - Added test for safe_asterisk
|
|
# - Changed "stop gracefully" to "stop now"
|
|
# - Added support for -U and -G command line options
|
|
# - Modified "reload" to call asterisk -rx 'reload'
|
|
|
|
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
|
NAME=asterisk
|
|
DESC="Asterisk PBX"
|
|
# Full path to asterisk binary
|
|
DAEMON=__ASTERISK_SBIN_DIR__/asterisk
|
|
ASTVARRUNDIR=__ASTERISK_VARRUN_DIR__
|
|
ASTETCDIR=__ASTERISK_ETC_DIR__
|
|
TRUE=/bin/true
|
|
|
|
### BEGIN INIT INFO
|
|
# Provides: asterisk
|
|
# Required-Start: $network $syslog $named $local_fs $remote_fs
|
|
# Required-Stop: $network $syslog $named $local_fs $remote_fs
|
|
# Should-Start: dahdi misdn lcr wanrouter mysql postgresql
|
|
# Should-Stop: dahdi misdn lcr wanrouter mysql postgresql
|
|
# Default-Start: 2 3 4 5
|
|
# Default-Stop: 0 1 6
|
|
# Short-Description: Asterisk PBX
|
|
# Description: the Asterisk Open Source PBX
|
|
### END INIT INFO
|
|
|
|
set -e
|
|
|
|
if ! [ -x $DAEMON ] ; then
|
|
echo "ERROR: $DAEMON not found"
|
|
exit 0
|
|
fi
|
|
|
|
if ! [ -d $ASTETCDIR ] ; then
|
|
echo "ERROR: $ASTETCDIR directory not found"
|
|
exit 0
|
|
fi
|
|
|
|
# Use the LSB standard functions for services management
|
|
. /lib/lsb/init-functions
|
|
|
|
# Allow configuration overrides in /etc/default/asterisk
|
|
CONFIG0=`readlink $0 || :` # readlink returns 1 when something isn't a symlink
|
|
if [ "$CONFIG0" = "" ]; then
|
|
CONFIGFILE=/etc/default/`basename $0`
|
|
else
|
|
CONFIGFILE=/etc/default/`basename $CONFIG0`
|
|
fi
|
|
[ -r $CONFIGFILE ] && . $CONFIGFILE
|
|
|
|
case "$1" in
|
|
start)
|
|
# Check if Asterisk is already running. If it is, then bug out, because
|
|
# starting up Asterisk when Asterisk is already running is very bad.
|
|
VERSION=`${DAEMON} -rx 'core show version' 2>/dev/null || ${TRUE}`
|
|
if [ "`echo $VERSION | cut -c 1-8`" = "Asterisk" ]; then
|
|
echo "Asterisk is already running. $0 will exit now."
|
|
exit 0
|
|
fi
|
|
|
|
log_begin_msg "Starting $DESC: $NAME"
|
|
if [ ! -d $ASTVARRUNDIR ]; then
|
|
mkdir -p $ASTVARRUNDIR
|
|
fi
|
|
if [ $AST_USER ] ; then
|
|
ASTARGS="-U $AST_USER"
|
|
chown $AST_USER $ASTVARRUNDIR
|
|
fi
|
|
if [ $AST_GROUP ] ; then
|
|
ASTARGS="$ASTARGS -G $AST_GROUP"
|
|
chgrp $AST_GROUP $ASTVARRUNDIR
|
|
fi
|
|
if [ $ALTCONF ]; then
|
|
ASTARGS="$ASTARGS -C \"$ALTCONF\""
|
|
fi
|
|
if [ "x$COREDUMP" = "xyes" ]; then
|
|
ASTARGS="$ASTARGS -g"
|
|
fi
|
|
if [ "0$MAXLOAD" -gt "0" ]; then
|
|
ASTARGS="$ASTARGS -L $MAXLOAD"
|
|
fi
|
|
if [ "0$MAXCALLS" -gt "0" ]; then
|
|
ASTARGS="$ASTARGS -M $MAXCALLS"
|
|
fi
|
|
if [ "0$VERBOSITY" -gt "0" ]; then
|
|
for i in `seq 1 $VERBOSITY`; do
|
|
ASTARGS="$ASTARGS -v"
|
|
done
|
|
# -v implies -f, so we override that implicit specification here
|
|
ASTARGS="$ASTARGS -F"
|
|
fi
|
|
if [ "x$INTERNALTIMING" = "xyes" ]; then
|
|
ASTARGS="$ASTARGS -I"
|
|
fi
|
|
if [ "x$TEMPRECORDINGLOCATION" = "xyes" -o "x$TMPRECORDINGLOCATION" = "xyes" ]; then
|
|
ASTARGS="$ASTARGS -t"
|
|
fi
|
|
if test "x$COLOR" = "xno" ; then
|
|
ASTARGS="$ASTARGS -n"
|
|
fi
|
|
# "start-stop-daemon --oknodo" returns 0 even if Asterisk was already running (as LSB expects):
|
|
start-stop-daemon --start --oknodo --exec $DAEMON -- $ASTARGS
|
|
log_end_msg $?
|
|
;;
|
|
stop)
|
|
log_begin_msg "Stopping $DESC: $NAME"
|
|
# "start-stop-daemon --oknodo" returns 0 even if Asterisk was already stopped (as LSB expects):
|
|
start-stop-daemon --stop --oknodo --exec $DAEMON
|
|
log_end_msg $?
|
|
;;
|
|
reload)
|
|
echo "Reloading $DESC configuration files."
|
|
$DAEMON -rx 'module reload' > /dev/null 2> /dev/null
|
|
;;
|
|
restart|force-reload)
|
|
$0 stop
|
|
sleep 2 # It needs some time to really be stopped.
|
|
$0 start
|
|
# "restart|force-reload" starts Asterisk and returns 0 even if Asterisk was stopped (as LSB expects).
|
|
;;
|
|
status)
|
|
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
|
|
;;
|
|
*)
|
|
N=/etc/init.d/$NAME
|
|
echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2
|
|
exit 1
|
|
;;
|
|
esac
|