mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 04:30:28 +00:00
Merged revisions 105113 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r105113 | tilghman | 2008-02-28 15:56:54 -0600 (Thu, 28 Feb 2008) | 7 lines Update init script for LSB compat (closes issue #9843) Reported by: ibc Patches: rc.debian.asterisk.patch uploaded by ibc (license 211) Tested by: paravoid ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@105176 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1,15 +1,17 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
# asterisk start the asterisk PBX
|
# 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".
|
||||||
|
# - Addded "--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>
|
# Thu Nov 17 2005 Gregory Boehnlein <damin@nacs.net>
|
||||||
# - Updated Version to 1.3
|
|
||||||
# - Reversed behavior of LD_ASSUME_KERNEL=2.4.1
|
# - Reversed behavior of LD_ASSUME_KERNEL=2.4.1
|
||||||
# - Added detailed failure messages
|
# - Added detailed failure messages
|
||||||
#
|
#
|
||||||
# Sun Jul 18 2004 Gregory Boehnlein <damin@nacs.net>
|
# Sun Jul 18 2004 Gregory Boehnlein <damin@nacs.net>
|
||||||
# - Updated Version to 1.2
|
|
||||||
# - Added test for safe_asterisk
|
# - Added test for safe_asterisk
|
||||||
# - Changed "stop gracefully" to "stop now"
|
# - Changed "stop gracefully" to "stop now"
|
||||||
# - Added support for -U and -G command line options
|
# - Added support for -U and -G command line options
|
||||||
@@ -21,9 +23,6 @@ DESC="Asterisk PBX"
|
|||||||
# Full path to asterisk binary
|
# Full path to asterisk binary
|
||||||
DAEMON=/usr/sbin/asterisk
|
DAEMON=/usr/sbin/asterisk
|
||||||
|
|
||||||
# Full path to safe_asterisk script
|
|
||||||
SAFE_ASTERISK=/usr/sbin/safe_asterisk
|
|
||||||
|
|
||||||
# Uncomment this ONLY if you know what you are doing.
|
# Uncomment this ONLY if you know what you are doing.
|
||||||
# export LD_ASSUME_KERNEL=2.4.1
|
# export LD_ASSUME_KERNEL=2.4.1
|
||||||
|
|
||||||
@@ -35,8 +34,10 @@ SAFE_ASTERISK=/usr/sbin/safe_asterisk
|
|||||||
#AST_USER="asterisk"
|
#AST_USER="asterisk"
|
||||||
#AST_GROUP="asterisk"
|
#AST_GROUP="asterisk"
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
if ! [ -x $DAEMON ] ; then
|
if ! [ -x $DAEMON ] ; then
|
||||||
echo "ERROR: /usr/sbin/asterisk not found"
|
echo "ERROR: $DAEMON not found"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -45,35 +46,37 @@ if ! [ -d /etc/asterisk ] ; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set -e
|
# Use the LSB standar functions for services management
|
||||||
|
. /lib/lsb/init-functions
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
echo -n "Starting $DESC: "
|
log_begin_msg "Starting $DESC: $NAME"
|
||||||
if [ -f $SAFE_ASTERISK ] ; then
|
|
||||||
DAEMON=$SAFE_ASTERISK
|
|
||||||
fi
|
|
||||||
if [ $AST_USER ] ; then
|
if [ $AST_USER ] ; then
|
||||||
ASTARGS="-U $AST_USER"
|
ASTARGS="-U $AST_USER"
|
||||||
fi
|
fi
|
||||||
if [ $AST_GROUP ] ; then
|
if [ $AST_GROUP ] ; then
|
||||||
ASTARGS="`echo $ASTARGS` -G $AST_GROUP"
|
ASTARGS="$ASTARGS -G $AST_GROUP"
|
||||||
fi
|
fi
|
||||||
start-stop-daemon --start --exec $DAEMON -- $ASTARGS
|
# "start-stop-daemon --oknodo" returns 0 even if Asterisk was already running (as LSB expects):
|
||||||
echo "$NAME."
|
start-stop-daemon --start --oknodo --exec $DAEMON -- $ASTARGS
|
||||||
|
log_end_msg $?
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
echo -n "Stopping $DESC: "
|
log_begin_msg "Stopping $DESC: $NAME"
|
||||||
$DAEMON -rx 'stop now' > /dev/null 2> /dev/null && echo -n "$NAME"
|
# "start-stop-daemon --oknodo" returns 0 even if Asterisk was already stopped (as LSB expects):
|
||||||
echo "."
|
start-stop-daemon --stop --oknodo --exec $DAEMON
|
||||||
exit 0
|
log_end_msg $?
|
||||||
;;
|
;;
|
||||||
reload)
|
reload)
|
||||||
echo "Reloading $DESC configuration files."
|
echo "Reloading $DESC configuration files."
|
||||||
$DAEMON -rx 'reload' > /dev/null 2> /dev/null
|
$DAEMON -rx 'reload' > /dev/null 2> /dev/null
|
||||||
;;
|
;;
|
||||||
restart|force-reload)
|
restart|force-reload)
|
||||||
$DAEMON -rx 'restart gracefully' > /dev/null 2> /dev/null && echo -n "$NAME"
|
$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).
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
N=/etc/init.d/$NAME
|
N=/etc/init.d/$NAME
|
||||||
@@ -81,5 +84,3 @@ case "$1" in
|
|||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
Reference in New Issue
Block a user