b039500
From 821affc49f8970cd2d16c22d528025db24b95f58 Mon Sep 17 00:00:00 2001
b039500
From: "Jeffrey C. Ollie" <jeff@ocjtech.us>
149b019
Date: Wed, 28 Jul 2010 07:22:21 -0500
29eb470
Subject: [PATCH 1/6] Modify init scripts for better Fedora compatibilty.
149b019
149b019
---
a4d5529
 contrib/init.d/rc.redhat.asterisk |   70 ++++++++++++++++++++-----------------
a4d5529
 contrib/sysconfig/asterisk        |   19 ++++++++++
a4d5529
 2 files changed, 57 insertions(+), 32 deletions(-)
149b019
 create mode 100644 contrib/sysconfig/asterisk
149b019
149b019
diff --git a/contrib/init.d/rc.redhat.asterisk b/contrib/init.d/rc.redhat.asterisk
a4d5529
index abf3951..0d53a57 100755
149b019
--- a/contrib/init.d/rc.redhat.asterisk
149b019
+++ b/contrib/init.d/rc.redhat.asterisk
729de3c
@@ -3,7 +3,7 @@
729de3c
 #
729de3c
 # asterisk    Starts, Stops and Reloads Asterisk.
729de3c
 #
729de3c
-# chkconfig: 2345 90 60
729de3c
+# chkconfig: - 90 60
729de3c
 # description: Asterisk PBX and telephony daemon.
729de3c
 # processname: asterisk
149b019
 # pidfile: __ASTERISK_VARRUN_DIR__/asterisk.pid
a4d5529
@@ -32,8 +32,11 @@
a4d5529
 # Description:		the Asterisk Open Source PBX
a4d5529
 ### END INIT INFO
729de3c
 
729de3c
+# Do not modify this script to change any of the settings, instead
729de3c
+# edit /etc/sysconfig/asterisk
0cbcf0d
+
149b019
 # Use this option to specify a different configuration directory
149b019
-#AST_CONFIG=__ASTERISK_ETC_DIR__
149b019
+AST_CONFIG=__ASTERISK_ETC_DIR__/asterisk.conf
149b019
 
729de3c
 # Installation directory
149b019
 AST_SBIN=__ASTERISK_SBIN_DIR__
a4d5529
@@ -41,31 +44,39 @@ AST_SBIN=__ASTERISK_SBIN_DIR__
a4d5529
 # Source function library.
a4d5529
 . /etc/rc.d/init.d/functions
729de3c
 
d87117a
+# The user that Asterisk will run as.
729de3c
+AST_USER="asterisk"
d87117a
+
d87117a
+# If a user is specified above, Asterisk will change the group it runs
d87117a
+# as to the primary group of the user, as well as initialize the
d87117a
+# supplementary groups.  If you want to run Asterisk as a different
d87117a
+# group, set AST_GROUP to the group that Asterisk should run as.  Note
0cbcf0d
+# that this may break DAHDI devices as supplementary groups will not
d87117a
+# be initialized.
a4d5529
+#AST_GROUP="asterisk"
a4d5529
+
729de3c
+# Allow configuration overrides in /etc/sysconfig/asterisk
729de3c
+CONFIG0=`readlink $0`
729de3c
+if [ "$CONFIG0" = "" ]; then
729de3c
+	CONFIGFILE=/etc/sysconfig/`basename $0`
729de3c
+else
729de3c
+	CONFIGFILE=/etc/sysconfig/`basename $CONFIG0`
729de3c
+fi
729de3c
+[ -f $CONFIGFILE ] && . $CONFIGFILE
a4d5529
+
729de3c
 if ! [ -x $AST_SBIN/asterisk ] ; then
729de3c
 	echo "ERROR: $AST_SBIN/asterisk not found"
729de3c
 	exit 0
729de3c
 fi
729de3c
 
729de3c
-if ! [ -d $AST_CONFIG ] ; then
729de3c
-	echo "ERROR: $AST_CONFIG directory not found"
729de3c
+if ! [ -f $AST_CONFIG ] ; then
729de3c
+	echo "ERROR: $AST_CONFIG not found"
729de3c
 	exit 0
729de3c
 fi
729de3c
 
729de3c
 # Full path to asterisk binary
729de3c
 DAEMON=$AST_SBIN/asterisk
729de3c
 
729de3c
-# Full path to safe_asterisk script
729de3c
-SAFE_ASTERISK=$AST_SBIN/safe_asterisk
729de3c
-
729de3c
-# Allow configuration overrides in /etc/sysconfig/asterisk
729de3c
-CONFIG0=`readlink $0`
729de3c
-if [ "$CONFIG0" = "" ]; then
729de3c
-	CONFIGFILE=/etc/sysconfig/`basename $0`
729de3c
-else
729de3c
-	CONFIGFILE=/etc/sysconfig/`basename $CONFIG0`
729de3c
-fi
a4d5529
-[ -r $CONFIGFILE ] && . $CONFIGFILE
729de3c
-
729de3c
 RETVAL=0
729de3c
 
729de3c
 start() {
a4d5529
@@ -79,17 +90,18 @@ start() {
c5b498c
 
729de3c
 	# Start daemons.
729de3c
 	echo -n $"Starting asterisk: "
729de3c
-        if [ -f $SAFE_ASTERISK ] ; then
729de3c
-		DAEMON=$SAFE_ASTERISK
729de3c
-	fi
a4d5529
+
a4d5529
+	export HOME=~asterisk
a4d5529
+	cd $HOME
a4d5529
+
729de3c
 	if [ $AST_USER ] ; then
0cbcf0d
-		ASTARGS="-U $AST_USER"
a4d5529
+		AST_ARGS="$AST_ARGS -U $AST_USER"
729de3c
 	fi
0cbcf0d
 	if [ $AST_GROUP ] ; then
0cbcf0d
-		ASTARGS="$ASTARGS -G $AST_GROUP"
0cbcf0d
+		AST_ARGS="$AST_ARGS -G $AST_GROUP"
673e40b
 	fi
673e40b
 	if [ $AST_CONFIG ]; then
673e40b
-		ASTARGS="$ASTARGS -C $AST_CONFIG/asterisk.conf"
a4d5529
+		ASTARGS="$ASTARGS -C $AST_CONFIG"
a4d5529
 	elif [ $ALTCONF ]; then
a4d5529
 		ASTARGS="$ASTARGS -C $ALTCONF"
a4d5529
 	fi
a4d5529
@@ -115,9 +127,9 @@ start() {
a4d5529
 	fi
a4d5529
 	if [ "x$COLOR" = "xyes" ]; then
a4d5529
 		export TERM=linux
a4d5529
-		daemon sh -c "$DAEMON $ASTARGS -c" >/dev/null </dev/null 2>&1 &
a4d5529
+		daemon sh -c "$DAEMON $ASTARGS $AST_EXTRA_ARGS -c" >/dev/null </dev/null 2>&1 &
a4d5529
 	else
a4d5529
-		daemon $DAEMON $ASTARGS
a4d5529
+		daemon $DAEMON $ASTARGS $AST_EXTRA_ARGS
673e40b
 	fi
673e40b
 	RETVAL=$?
0cbcf0d
 	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/asterisk
a4d5529
@@ -126,14 +138,8 @@ start() {
4e74e55
 }
729de3c
 
729de3c
 stop() {
4e74e55
-	# Stop daemons.
4e74e55
-	if [ -f $SAFE_ASTERISK ]; then
4e74e55
-		# Kill safe_asterisk first, to prevent us from starting up 2 instances of safe_asterisk
4e74e55
-		echo -n $"Stopping safe_asterisk: "
4e74e55
-		killproc `basename $SAFE_ASTERISK`
4e74e55
-		echo
4e74e55
-	fi
729de3c
-	echo -n $"Shutting down asterisk: "
4e74e55
+	# Stop daemon.
729de3c
+	echo -n $"Stopping asterisk: "
4e74e55
 	killproc `basename $DAEMON`
729de3c
 	RETVAL=$?
729de3c
 	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/asterisk
149b019
diff --git a/contrib/sysconfig/asterisk b/contrib/sysconfig/asterisk
149b019
new file mode 100644
149b019
index 0000000..dab2e33
149b019
--- /dev/null
149b019
+++ b/contrib/sysconfig/asterisk
0cbcf0d
@@ -0,0 +1,19 @@
729de3c
+# Specify the configuration file
729de3c
+AST_CONFIG=/etc/asterisk/asterisk.conf
729de3c
+
729de3c
+# Installation directory
729de3c
+AST_SBIN=/usr/sbin
729de3c
+
d87117a
+# The user that Asterisk will run as.
729de3c
+AST_USER="asterisk"
d87117a
+
d87117a
+# If a user is specified above, Asterisk will change the group it runs
d87117a
+# as to the primary group of the user, as well as initialize the
d87117a
+# supplementary groups.  If you want to run Asterisk as a different
d87117a
+# group, set AST_GROUP to the group that Asterisk should run as.  Note
d87117a
+# that this may break Zaptel devices as supplementary groups will not
d87117a
+# be initialized.
d87117a
+#AST_GROUP="asterisk"
0cbcf0d
+
0cbcf0d
+# A place to specify extra arguments for the Asterisk command line
0cbcf0d
+AST_EXTRA_ARGS=""
149b019
-- 
b039500
1.7.5.2
149b019