updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / asterisk16-8layertech / asterisk.init
blobb9db8ab67bcbb6cfb4eec8d04bb37149b8a49d8a
1 #!/bin/bash
3 # Start/stop/restart Asterisk PBX
5 # Version: 0.1 by Sherif Nagy AKA DarKnesS_WolF <sherif.nagy@gmail.com> BASED ON THE SLACKWARE INIT SCRIPT
7 # 10.10.2008 - Initial Version
9 # Corrections by: Joel Bryan Juliano <jbjuliano@8layertech.com>
12 . /etc/rc.conf
13 . /etc/rc.d/functions
14 DAEMON=/usr/sbin/asterisk
15 ASTVARRUNDIR=/var/run/asterisk
17 case "$1" in
18 start)
19 stat_busy "Starting Asterisk..."
20 if [ ! -d $ASTVARRUNDIR ]; then
21 mkdir -p $ASTVARRUNDIR
23 if [ -x $DAEMON ]; then
24 # Check if Asterisk is already running. If it is, then bug out, because
25 # starting safe_asterisk when Asterisk is running is very bad.
26 VERSION=`${DAEMON} -rx 'core show version'`
27 if [ "`echo $VERSION | cut -c 1-8`" = "Asterisk" ]; then
28 echo "Asterisk is already running. $0 will exit now."
29 exit 1
31 ${DAEMON}
32 stat_done
35 stop)
36 if [ -r ${ASTVARRUNDIR}/asterisk.pid ]; then
37 stat_busy "Stopping Asterisk..."
38 ${DAEMON} -rx "core stop now" >/dev/null 2>/dev/null 1>/dev/null
39 if [ $? -gt 0 ]; then
40 stat_fail
41 else
42 stat_done
46 restart)
47 $0 stop
48 sleep 2
49 $0 start
52 echo "usage $0 start|stop|restart" ;;
53 esac
54 exit 0