asterisk/contrib/init.d/rc.slackware.asterisk

63 lines
1.5 KiB
Plaintext
Raw Normal View History

#!/bin/sh
#
# Start/stop/restart Asterisk PBX
#
# Version: 1.0 - Paul Belanger <pabelanger@gmail.com>
#
# 03.29.2005 - Initial Version
#
# $Id$
### 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
asterisk_start() {
if [ -x /usr/sbin/asterisk ]; then
# Check if Asterisk is already running. If it is, then bug out, because
# starting safe_asterisk when Asterisk is running is very bad.
Update init.d scripts to handle stderr; readd splash screen for remote consoles 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
2013-01-21 20:41:12 +00:00
VERSION=`/usr/sbin/asterisk -rx 'core show version' 2>/dev/null`
if [ "`echo $VERSION | cut -c 1-8`" = "Asterisk" ]; then
echo "Asterisk is already running. $0 will exit now."
exit 1
fi
echo "Starting Asterisk /usr/sbin/asterisk"
/usr/sbin/asterisk
fi
}
asterisk_stop() {
# If there is no PID file, ignore this request...
if [ -r /var/run/asterisk.pid ]; then
killall asterisk
fi
}
asterisk_restart() {
asterisk_stop
asterisk_start
}
case "$1" in
'start')
asterisk_start
;;
'stop')
asterisk_stop
;;
'restart')
asterisk_restart
;;
*)
echo "usage $0 start|stop|restart" ;;
esac