From 24dbdf83caa3ed8deb411d985db2408e32ca13bc Mon Sep 17 00:00:00 2001 From: tilghman Date: Mon, 4 Aug 2008 17:12:15 +0000 Subject: Rename Mandrake scripts to Mandriva (Closes issue #13221) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@135485 f38db490-d61c-443f-a65b-d21fe96a405b --- Makefile | 2 +- contrib/init.d/rc.mandrake.asterisk | 195 ------------------------------------ contrib/init.d/rc.mandrake.zaptel | 108 -------------------- contrib/init.d/rc.mandriva.asterisk | 195 ++++++++++++++++++++++++++++++++++++ contrib/init.d/rc.mandriva.zaptel | 108 ++++++++++++++++++++ 5 files changed, 304 insertions(+), 304 deletions(-) delete mode 100755 contrib/init.d/rc.mandrake.asterisk delete mode 100755 contrib/init.d/rc.mandrake.zaptel create mode 100755 contrib/init.d/rc.mandriva.asterisk create mode 100755 contrib/init.d/rc.mandriva.zaptel diff --git a/Makefile b/Makefile index 99d804e48..5a95a4e65 100644 --- a/Makefile +++ b/Makefile @@ -786,7 +786,7 @@ config: $(INSTALL) -m 755 contrib/init.d/rc.gentoo.asterisk $(DESTDIR)/etc/init.d/asterisk; \ if [ -z "$(DESTDIR)" ]; then /sbin/rc-update add asterisk default; fi; \ elif [ -f /etc/mandrake-release -o -f /etc/mandriva-release ]; then \ - $(INSTALL) -m 755 contrib/init.d/rc.mandrake.asterisk $(DESTDIR)/etc/rc.d/init.d/asterisk; \ + $(INSTALL) -m 755 contrib/init.d/rc.mandriva.asterisk $(DESTDIR)/etc/rc.d/init.d/asterisk; \ if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \ elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then \ $(INSTALL) -m 755 contrib/init.d/rc.suse.asterisk $(DESTDIR)/etc/init.d/asterisk; \ diff --git a/contrib/init.d/rc.mandrake.asterisk b/contrib/init.d/rc.mandrake.asterisk deleted file mode 100755 index daea07150..000000000 --- a/contrib/init.d/rc.mandrake.asterisk +++ /dev/null @@ -1,195 +0,0 @@ -#!/bin/sh -# -# asterisk: Starts the asterisk service -# -# Version: @(#) /etc/rc.d/init.d/asterisk 1.0 -# -# chkconfig: 2345 95 10 -# description: Starts the asterisk service -# -# processname: asterisk -# - -# $Id$ - -TTY=9 # TTY (if you want one) for Asterisk to run on -CONSOLE=yes # Whether or not you want a console -NOTIFY=root # Who to notify about crashes -DUMPDROP=/tmp -HOSTNAME=`hostname` -ASTSBINDIR=/usr/sbin - -if [ 0`readlink $0` = "0" ]; then - CONFIGFILE=/etc/sysconfig/`basename $0` -else - CONFIG0=`readlink $0` - CONFIGFILE=/etc/sysconfig/`basename $CONFIG0` -fi - -# Setup environment -cd /usr/src -if [ -f /usr/lib/asterisk/modules/chan_h323.so -a `grep -c ^noload=chan_h323.so /etc/asterisk/modules.conf` -eq 0 ]; then - OPENH323DIR=/usr/src/h323/openh323 - PWLIBDIR=/usr/src/h323/pwlib -else - OPENH323DIR=/usr/src/oh323/openh323 - PWLIBDIR=/usr/src/oh323/pwlib -fi - -# Put overrides in /etc/sysconfig/asterisk -[ -f $CONFIGFILE ] && . $CONFIGFILE - -LD_LIBRARY_PATH=$OPENH323DIR/lib:$PWLIBDIR/lib -export OPENH323DIR PWLIBDIR LD_LIBRARY_PATH - -# Source function library. -. /etc/rc.d/init.d/functions - -# -# Don't fork when running "safely" -# -ASTARGS="-p" -if [ "$TTY" != "" ]; then - if [ -c /dev/tty${TTY} ]; then - TTY=tty${TTY} - elif [ -c /dev/vc/${TTY} ]; then - TTY=vc/${TTY} - else - echo "Cannot find your TTY (${TTY})" >&2 - exit 1 - fi - ASTARGS="${ASTARGS} -vvv" - if [ "$CONSOLE" != "no" ]; then - ASTARGS="${ASTARGS} -c" - fi -fi -if [ ! -w ${DUMPDROP} ]; then - echo "Cannot write to ${DUMPDROP}" >&2 - exit 1 -fi - -# -# Let Asterisk dump core -# -ulimit -c unlimited - -#launch_asterisk() -#{ -#} - -SIGMSG=("None", "Hangup" "Interrupt" "Quit" "Illegal instruction" "Trace trap" "IOT Trap" "Bus Error" "Floating-point exception" "Killed" "User-defined signal 1" "Segmentation violation" "User-defined signal 2" "Broken pipe" "Alarm clock" "Termination" "Stack fault") - -run_asterisk() -{ - while :; do - - if [ "$TTY" != "" ]; then - cd /tmp - stty sane < /dev/${TTY} - asterisk ${ASTARGS} > /dev/${TTY} 2>&1 < /dev/${TTY} - else - cd /tmp - asterisk ${ASTARGS} - fi - EXITSTATUS=$? - echo "Asterisk ended with exit status $EXITSTATUS" - if [ "$EXITSTATUS" = "0" ]; then - # Properly shutdown.... - echo "Asterisk shutdown normally." - exit 0 - elif [ $EXITSTATUS -gt 128 ]; then - EXITSIGNAL=$(($EXITSTATUS - 128)) - EXITMSG=${SIGMSG[$EXITSIGNAL]} - echo "Asterisk exited on signal $EXITSIGNAL - $EXITMSG." - if [ "$NOTIFY" != "" ]; then - echo "Asterisk exited on signal $EXITSIGNAL - $EXITMSG. Might want to take a peek." | \ - mail -s "Asterisk Died ($HOSTNAME)" $NOTIFY - fi - if [ -f /tmp/core ]; then - mv /tmp/core ${DUMPDROP}/core.`hostname`-`date -Iseconds` & - fi - else - echo "Asterisk died with code $EXITSTATUS. Aborting." - if [ -f /tmp/core ]; then - mv /tmp/core ${DUMPDROP}/core.`hostname`-`date -Iseconds` & - fi - exit 0 - fi - echo "Automatically restarting Asterisk." - done -} - -case "$1" in - start) - # Check if Asterisk is already running. If it is, then bug out, because - # starting Asterisk when Asterisk is already running is very bad. - VERSION=`${ASTSBINDIR}/asterisk -rx 'core show version'` - if [ "`echo $VERSION | cut -c 1-8`" = "Asterisk" ]; then - echo "Asterisk is already running. $0 will exit now." - exit 1 - fi - - gprintf "Starting asterisk: " - run_asterisk >/dev/null 2>&1 & - sleep 2 # Give it time to die - succeeded=`pidof asterisk|awk '{print NF}'` - if [ $succeeded = "0" ]; then - failure - else - success - fi - echo - ;; - stop) - gprintf "Stopping asterisk: " - asterisk -r -x "stop gracefully" >/dev/null 2>&1 - killall -9 mpg123 2>/dev/null - success - echo - ;; - restart) - $0 stop - usleep 100000 - $0 start - ;; - reload) - gprintf "Reloading asterisk: " - asterisk -r -x "reload" >/dev/null 2>&1 - success - echo - ;; - stopnow) - gprintf "Stopping asterisk: " - asterisk -r -x "stop now" >/dev/null 2>&1 - success - echo - ;; - restartnow) - $0 stopnow - $0 start - ;; - fullrestart) - $0 stop - service dahdi restart - $0 start - ;; - fullrestartnow) - $0 stopnow - service dahdi restart - $0 start - ;; - status) - succeeded=`pidof asterisk|awk '{print NF}'` - if [ $succeeded = "0" ]; then - echo "Asterisk is not running" - else - echo "Asterisk is currently running with $succeeded threads" - fi - ;; - *) - gprintf "*** Usage: $0 {start|stop[now]|reload|[full]restart[now]|status}\n" - exit 1 -esac - -exit 0 - diff --git a/contrib/init.d/rc.mandrake.zaptel b/contrib/init.d/rc.mandrake.zaptel deleted file mode 100755 index 14a658b41..000000000 --- a/contrib/init.d/rc.mandrake.zaptel +++ /dev/null @@ -1,108 +0,0 @@ -#!/bin/sh -# -# DAHDI: Loads Asterisk modules -# -# Version: @(#) /etc/rc.d/init.d/dahdi 1.0 -# -# chkconfig: 2345 90 10 -# description: Loads and unloads DAHDI modules at boot time and shutdown. -# -# hide: true - -# $Id$ - -# Source function library. -. /etc/rc.d/init.d/functions - -# Default modules - override in /etc/sysconfig/dahdi -###################################### -MODULES="usb-uhci dahdi wcfxo wcusb" -###################################### - -# Resolve back to the basename (i.e. dahdi, not S90dahdi) -if [ 0`readlink $0` = "0" ]; then - CONFIGFILE=/etc/sysconfig/`basename $0` -else - CONFIG0=`readlink $0` - CONFIGFILE=/etc/sysconfig/`basename $CONFIG0` -fi - -[ -f $CONFIGFILE ] && . $CONFIGFILE - -function probe() { - gprintf " $1" - modprobe -i $1 - # It has to be in the module list, otherwise something is wrong - if lsmod | grep -c ^$1 >/dev/null; then - success - else - failure - fi - echo -} - -function unprobe() { - gprintf " $1" - rmmod $1 >/dev/null 2>&1 - # If it's still in the module list after removing it, there's something wrong. - if lsmod | grep -c ^$1 >/dev/null; then - failure - else - success - fi - echo -} - -function reverse_modules() { - tmp=$MODULES - MODULES='' - for i in $tmp; do - MODULES="$i $MODULES" ; - done -} - -# See how we were called. -case "$1" in - start) - gprintf "Loading Asterisk modules:\n" - for i in $MODULES; do - probe $i - usleep 100000 ; - done - ztcfg - ;; - stop) - gprintf "Unloading Asterisk modules:\n" - reverse_modules - for i in $MODULES; do - unprobe $i - usleep 100000 ; - done - ;; - status) - #ztcfg -vv - OK=1 - gprintf "Checking Asterisk modules" - for i in $MODULES; do - if [ `lsmod | grep -c $i` -eq 0 ]; then - OK=0 - fi - done - if [ $OK -gt 0 ]; then - success - else - failure - fi - echo - ;; - restart) - $0 stop - $0 start - ;; - *) - gprintf "*** Usage: $0 {start|stop|status|restart}\n" - exit 1 -esac - -exit 0 - diff --git a/contrib/init.d/rc.mandriva.asterisk b/contrib/init.d/rc.mandriva.asterisk new file mode 100755 index 000000000..daea07150 --- /dev/null +++ b/contrib/init.d/rc.mandriva.asterisk @@ -0,0 +1,195 @@ +#!/bin/sh +# +# asterisk: Starts the asterisk service +# +# Version: @(#) /etc/rc.d/init.d/asterisk 1.0 +# +# chkconfig: 2345 95 10 +# description: Starts the asterisk service +# +# processname: asterisk +# + +# $Id$ + +TTY=9 # TTY (if you want one) for Asterisk to run on +CONSOLE=yes # Whether or not you want a console +NOTIFY=root # Who to notify about crashes +DUMPDROP=/tmp +HOSTNAME=`hostname` +ASTSBINDIR=/usr/sbin + +if [ 0`readlink $0` = "0" ]; then + CONFIGFILE=/etc/sysconfig/`basename $0` +else + CONFIG0=`readlink $0` + CONFIGFILE=/etc/sysconfig/`basename $CONFIG0` +fi + +# Setup environment +cd /usr/src +if [ -f /usr/lib/asterisk/modules/chan_h323.so -a `grep -c ^noload=chan_h323.so /etc/asterisk/modules.conf` -eq 0 ]; then + OPENH323DIR=/usr/src/h323/openh323 + PWLIBDIR=/usr/src/h323/pwlib +else + OPENH323DIR=/usr/src/oh323/openh323 + PWLIBDIR=/usr/src/oh323/pwlib +fi + +# Put overrides in /etc/sysconfig/asterisk +[ -f $CONFIGFILE ] && . $CONFIGFILE + +LD_LIBRARY_PATH=$OPENH323DIR/lib:$PWLIBDIR/lib +export OPENH323DIR PWLIBDIR LD_LIBRARY_PATH + +# Source function library. +. /etc/rc.d/init.d/functions + +# +# Don't fork when running "safely" +# +ASTARGS="-p" +if [ "$TTY" != "" ]; then + if [ -c /dev/tty${TTY} ]; then + TTY=tty${TTY} + elif [ -c /dev/vc/${TTY} ]; then + TTY=vc/${TTY} + else + echo "Cannot find your TTY (${TTY})" >&2 + exit 1 + fi + ASTARGS="${ASTARGS} -vvv" + if [ "$CONSOLE" != "no" ]; then + ASTARGS="${ASTARGS} -c" + fi +fi +if [ ! -w ${DUMPDROP} ]; then + echo "Cannot write to ${DUMPDROP}" >&2 + exit 1 +fi + +# +# Let Asterisk dump core +# +ulimit -c unlimited + +#launch_asterisk() +#{ +#} + +SIGMSG=("None", "Hangup" "Interrupt" "Quit" "Illegal instruction" "Trace trap" "IOT Trap" "Bus Error" "Floating-point exception" "Killed" "User-defined signal 1" "Segmentation violation" "User-defined signal 2" "Broken pipe" "Alarm clock" "Termination" "Stack fault") + +run_asterisk() +{ + while :; do + + if [ "$TTY" != "" ]; then + cd /tmp + stty sane < /dev/${TTY} + asterisk ${ASTARGS} > /dev/${TTY} 2>&1 < /dev/${TTY} + else + cd /tmp + asterisk ${ASTARGS} + fi + EXITSTATUS=$? + echo "Asterisk ended with exit status $EXITSTATUS" + if [ "$EXITSTATUS" = "0" ]; then + # Properly shutdown.... + echo "Asterisk shutdown normally." + exit 0 + elif [ $EXITSTATUS -gt 128 ]; then + EXITSIGNAL=$(($EXITSTATUS - 128)) + EXITMSG=${SIGMSG[$EXITSIGNAL]} + echo "Asterisk exited on signal $EXITSIGNAL - $EXITMSG." + if [ "$NOTIFY" != "" ]; then + echo "Asterisk exited on signal $EXITSIGNAL - $EXITMSG. Might want to take a peek." | \ + mail -s "Asterisk Died ($HOSTNAME)" $NOTIFY + fi + if [ -f /tmp/core ]; then + mv /tmp/core ${DUMPDROP}/core.`hostname`-`date -Iseconds` & + fi + else + echo "Asterisk died with code $EXITSTATUS. Aborting." + if [ -f /tmp/core ]; then + mv /tmp/core ${DUMPDROP}/core.`hostname`-`date -Iseconds` & + fi + exit 0 + fi + echo "Automatically restarting Asterisk." + done +} + +case "$1" in + start) + # Check if Asterisk is already running. If it is, then bug out, because + # starting Asterisk when Asterisk is already running is very bad. + VERSION=`${ASTSBINDIR}/asterisk -rx 'core show version'` + if [ "`echo $VERSION | cut -c 1-8`" = "Asterisk" ]; then + echo "Asterisk is already running. $0 will exit now." + exit 1 + fi + + gprintf "Starting asterisk: " + run_asterisk >/dev/null 2>&1 & + sleep 2 # Give it time to die + succeeded=`pidof asterisk|awk '{print NF}'` + if [ $succeeded = "0" ]; then + failure + else + success + fi + echo + ;; + stop) + gprintf "Stopping asterisk: " + asterisk -r -x "stop gracefully" >/dev/null 2>&1 + killall -9 mpg123 2>/dev/null + success + echo + ;; + restart) + $0 stop + usleep 100000 + $0 start + ;; + reload) + gprintf "Reloading asterisk: " + asterisk -r -x "reload" >/dev/null 2>&1 + success + echo + ;; + stopnow) + gprintf "Stopping asterisk: " + asterisk -r -x "stop now" >/dev/null 2>&1 + success + echo + ;; + restartnow) + $0 stopnow + $0 start + ;; + fullrestart) + $0 stop + service dahdi restart + $0 start + ;; + fullrestartnow) + $0 stopnow + service dahdi restart + $0 start + ;; + status) + succeeded=`pidof asterisk|awk '{print NF}'` + if [ $succeeded = "0" ]; then + echo "Asterisk is not running" + else + echo "Asterisk is currently running with $succeeded threads" + fi + ;; + *) + gprintf "*** Usage: $0 {start|stop[now]|reload|[full]restart[now]|status}\n" + exit 1 +esac + +exit 0 + diff --git a/contrib/init.d/rc.mandriva.zaptel b/contrib/init.d/rc.mandriva.zaptel new file mode 100755 index 000000000..14a658b41 --- /dev/null +++ b/contrib/init.d/rc.mandriva.zaptel @@ -0,0 +1,108 @@ +#!/bin/sh +# +# DAHDI: Loads Asterisk modules +# +# Version: @(#) /etc/rc.d/init.d/dahdi 1.0 +# +# chkconfig: 2345 90 10 +# description: Loads and unloads DAHDI modules at boot time and shutdown. +# +# hide: true + +# $Id$ + +# Source function library. +. /etc/rc.d/init.d/functions + +# Default modules - override in /etc/sysconfig/dahdi +###################################### +MODULES="usb-uhci dahdi wcfxo wcusb" +###################################### + +# Resolve back to the basename (i.e. dahdi, not S90dahdi) +if [ 0`readlink $0` = "0" ]; then + CONFIGFILE=/etc/sysconfig/`basename $0` +else + CONFIG0=`readlink $0` + CONFIGFILE=/etc/sysconfig/`basename $CONFIG0` +fi + +[ -f $CONFIGFILE ] && . $CONFIGFILE + +function probe() { + gprintf " $1" + modprobe -i $1 + # It has to be in the module list, otherwise something is wrong + if lsmod | grep -c ^$1 >/dev/null; then + success + else + failure + fi + echo +} + +function unprobe() { + gprintf " $1" + rmmod $1 >/dev/null 2>&1 + # If it's still in the module list after removing it, there's something wrong. + if lsmod | grep -c ^$1 >/dev/null; then + failure + else + success + fi + echo +} + +function reverse_modules() { + tmp=$MODULES + MODULES='' + for i in $tmp; do + MODULES="$i $MODULES" ; + done +} + +# See how we were called. +case "$1" in + start) + gprintf "Loading Asterisk modules:\n" + for i in $MODULES; do + probe $i + usleep 100000 ; + done + ztcfg + ;; + stop) + gprintf "Unloading Asterisk modules:\n" + reverse_modules + for i in $MODULES; do + unprobe $i + usleep 100000 ; + done + ;; + status) + #ztcfg -vv + OK=1 + gprintf "Checking Asterisk modules" + for i in $MODULES; do + if [ `lsmod | grep -c $i` -eq 0 ]; then + OK=0 + fi + done + if [ $OK -gt 0 ]; then + success + else + failure + fi + echo + ;; + restart) + $0 stop + $0 start + ;; + *) + gprintf "*** Usage: $0 {start|stop|status|restart}\n" + exit 1 +esac + +exit 0 + -- cgit v1.2.3