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