#!/bin/sh
-# $Id: asterisk,v 1.2 2004/07/18 20:24:07 Gregory Boehnlein <damin@nacs.net>
+# $Id: asterisk,v 1.3 2005/11/17 22:30:01 Gregory Boehnlein <damin@nacs.net>
#
# asterisk Starts, Stops and Reloads Asterisk.
#
-# chkconfig: 2345 40 60
+# 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
# - Added support for -U and -G command line options
# - Modified "reload" to call asterisk -rx 'reload'
-# Source function library.
-. /etc/rc.d/init.d/functions
-
-[ -x /usr/sbin/asterisk ] || exit 0
-[ -d /etc/asterisk ] || exit 0
-
-# Leave this set unless you know what you are doing.
-export LD_ASSUME_KERNEL=2.4.1
+# Use this option to specify a different configuration directory
+#AST_CONFIG=/etc/asterisk
-# Full path to asterisk binary
-DAEMON=/usr/sbin/asterisk
-
-# Full path to safe_asterisk script
-SAFE_ASTERISK=/usr/sbin/safe_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
#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() {
ASTARGS="-U $AST_USER"
fi
if [ $AST_GROUP ] ; then
- ASTARGS="`echo $ASTARGS` -G $AST_GROUP"
+ ASTARGS="$ASTARGS -G $AST_GROUP"
+ fi
+ if [ $AST_CONFIG ]; then
+ ASTARGS="$ASTARGS -C $AST_CONFIG"
fi
daemon $DAEMON $ASTARGS
RETVAL=$?