aboutsummaryrefslogtreecommitdiffstats
path: root/trunk/contrib/init.d
diff options
context:
space:
mode:
Diffstat (limited to 'trunk/contrib/init.d')
-rwxr-xr-xtrunk/contrib/init.d/rc.debian.asterisk85
-rwxr-xr-xtrunk/contrib/init.d/rc.gentoo.asterisk18
-rwxr-xr-xtrunk/contrib/init.d/rc.mandrake.asterisk185
-rwxr-xr-xtrunk/contrib/init.d/rc.mandrake.zaptel108
-rwxr-xr-xtrunk/contrib/init.d/rc.redhat.asterisk136
-rwxr-xr-xtrunk/contrib/init.d/rc.slackware.asterisk43
-rwxr-xr-xtrunk/contrib/init.d/rc.suse.asterisk127
7 files changed, 702 insertions, 0 deletions
diff --git a/trunk/contrib/init.d/rc.debian.asterisk b/trunk/contrib/init.d/rc.debian.asterisk
new file mode 100755
index 000000000..3926346d4
--- /dev/null
+++ b/trunk/contrib/init.d/rc.debian.asterisk
@@ -0,0 +1,85 @@
+#! /bin/sh
+# $Id$
+#
+# asterisk start the asterisk PBX
+#
+# 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
+# - Changed "stop gracefully" to "stop now"
+# - Added support for -U and -G command line options
+# - Modified "reload" to call asterisk -rx 'reload'
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+NAME=asterisk
+DESC="Asterisk PBX"
+# Full path to asterisk binary
+DAEMON=/usr/sbin/asterisk
+
+# Full path to safe_asterisk script
+SAFE_ASTERISK=/usr/sbin/safe_asterisk
+
+# Uncomment this ONLY if you know what you are doing.
+# export LD_ASSUME_KERNEL=2.4.1
+
+# Uncomment the following and set them to the user/groups that you
+# want to run Asterisk as. NOTE: this requires substantial work to
+# be sure that Asterisk's environment has permission to write the
+# files required for its operation, including logs, its comm
+# socket, the asterisk database, etc.
+#AST_USER="asterisk"
+#AST_GROUP="asterisk"
+
+if ! [ -x $DAEMON ] ; then
+ echo "ERROR: /usr/sbin/asterisk not found"
+ exit 0
+fi
+
+if ! [ -d /etc/asterisk ] ; then
+ echo "ERROR: /etc/asterisk directory not found"
+ exit 0
+fi
+
+set -e
+
+case "$1" in
+ start)
+ echo -n "Starting $DESC: "
+ if [ -f $SAFE_ASTERISK ] ; then
+ DAEMON=$SAFE_ASTERISK
+ fi
+ if [ $AST_USER ] ; then
+ ASTARGS="-U $AST_USER"
+ fi
+ if [ $AST_GROUP ] ; then
+ ASTARGS="`echo $ASTARGS` -G $AST_GROUP"
+ fi
+ start-stop-daemon --start --exec $DAEMON -- $ASTARGS
+ echo "$NAME."
+ ;;
+ stop)
+ echo -n "Stopping $DESC: "
+ $DAEMON -rx 'stop now' > /dev/null 2> /dev/null && echo -n "$NAME"
+ echo "."
+ exit 0
+ ;;
+ reload)
+ echo "Reloading $DESC configuration files."
+ $DAEMON -rx 'reload' > /dev/null 2> /dev/null
+ ;;
+ restart|force-reload)
+ $DAEMON -rx 'restart gracefully' > /dev/null 2> /dev/null && echo -n "$NAME"
+ ;;
+ *)
+ N=/etc/init.d/$NAME
+ echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/trunk/contrib/init.d/rc.gentoo.asterisk b/trunk/contrib/init.d/rc.gentoo.asterisk
new file mode 100755
index 000000000..3d963d6c0
--- /dev/null
+++ b/trunk/contrib/init.d/rc.gentoo.asterisk
@@ -0,0 +1,18 @@
+#!/sbin/runscript
+# $Id$
+
+depend() {
+ need net logger
+}
+
+start() {
+ ebegin "Starting Asterisk"
+ /usr/sbin/asterisk
+ eend $? "Failed to start Asterisk"
+}
+
+stop() {
+ ebegin "Stopping Asterisk"
+ kill $(cat /var/run/asterisk.pid)
+ eend $? "Failed to stop Asterisk"
+}
diff --git a/trunk/contrib/init.d/rc.mandrake.asterisk b/trunk/contrib/init.d/rc.mandrake.asterisk
new file mode 100755
index 000000000..1ffd25d37
--- /dev/null
+++ b/trunk/contrib/init.d/rc.mandrake.asterisk
@@ -0,0 +1,185 @@
+#!/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`
+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)
+ 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 zaptel restart
+ $0 start
+ ;;
+ fullrestartnow)
+ $0 stopnow
+ service zaptel 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/trunk/contrib/init.d/rc.mandrake.zaptel b/trunk/contrib/init.d/rc.mandrake.zaptel
new file mode 100755
index 000000000..2feaef4c7
--- /dev/null
+++ b/trunk/contrib/init.d/rc.mandrake.zaptel
@@ -0,0 +1,108 @@
+#!/bin/sh
+#
+# zaptel: Loads Asterisk modules
+#
+# Version: @(#) /etc/rc.d/init.d/zaptel 1.0
+#
+# chkconfig: 2345 90 10
+# description: Loads and unloads zaptel modules at boot time and shutdown.
+#
+# hide: true
+
+# $Id$
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+# Default modules - override in /etc/sysconfig/zaptel
+######################################
+MODULES="usb-uhci zaptel wcfxo wcusb"
+######################################
+
+# Resolve back to the basename (i.e. zaptel, not S90zaptel)
+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/trunk/contrib/init.d/rc.redhat.asterisk b/trunk/contrib/init.d/rc.redhat.asterisk
new file mode 100755
index 000000000..27d633e70
--- /dev/null
+++ b/trunk/contrib/init.d/rc.redhat.asterisk
@@ -0,0 +1,136 @@
+#!/bin/sh
+# $Id$
+#
+# asterisk Starts, Stops and Reloads Asterisk.
+#
+# 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
+# - Verified SIGTERM issued by "killproc" ensures "stop gracefully"
+# - Added support for -U and -G command line options
+# - Modified "reload" to call asterisk -rx 'reload'
+
+# Use this option to specify a different configuration directory
+#AST_CONFIG=/etc/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
+# be sure that Asterisk's environment has permission to write the
+# files required for its operation, including logs, its comm
+# socket, the asterisk database, etc.
+#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() {
+ # Start daemons.
+ echo -n $"Starting asterisk: "
+ if [ -f $SAFE_ASTERISK ] ; then
+ DAEMON=$SAFE_ASTERISK
+ fi
+ if [ $AST_USER ] ; then
+ ASTARGS="-U $AST_USER"
+ fi
+ if [ $AST_GROUP ] ; then
+ ASTARGS="$ASTARGS -G $AST_GROUP"
+ fi
+ if [ $AST_CONFIG ]; then
+ ASTARGS="$ASTARGS -C $AST_CONFIG"
+ fi
+ daemon $DAEMON $ASTARGS
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/asterisk
+ echo
+ return $RETVAL
+}
+
+stop() {
+ # Stop daemons.
+ echo -n $"Shutting down asterisk: "
+ killproc asterisk
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/asterisk
+ echo
+ return $RETVAL
+}
+
+restart() {
+ stop
+ start
+}
+
+reload() {
+ $DAEMON -rx 'reload' > /dev/null 2> /dev/null
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ restart
+ ;;
+ reload)
+ reload
+ ;;
+ condrestart)
+ [ -f /var/lock/subsys/asterisk ] && restart || :
+ ;;
+ status)
+ status asterisk
+ ;;
+ *)
+ echo "Usage: asterisk {start|stop|restart|reload|condrestart|status}"
+ exit 1
+esac
+
+exit $?
diff --git a/trunk/contrib/init.d/rc.slackware.asterisk b/trunk/contrib/init.d/rc.slackware.asterisk
new file mode 100755
index 000000000..0802bfcaa
--- /dev/null
+++ b/trunk/contrib/init.d/rc.slackware.asterisk
@@ -0,0 +1,43 @@
+#!/bin/sh
+#
+# Start/stop/restart Asterisk PBX
+#
+# Version: 1.0 - Paul Belanger <pabelanger@gmail.com>
+#
+# 03.29.2005 - Initial Version
+#
+# $Id$
+
+asterisk_start() {
+ if [ -x /usr/sbin/asterisk ]; then
+ echo "Starting Asterisk /usr/sbin/asterisk"
+ /usr/sbin/asterisk
+ fi
+}
+
+asterisk_stop() {
+ # If there is no PID file, ignore this request...
+ if [ -r /var/run/asterisk.pid ]; then
+ killall asterisk
+ fi
+}
+
+asterisk_restart() {
+ asterisk_stop
+ asterisk_start
+}
+
+case "$1" in
+ 'start')
+ asterisk_start
+ ;;
+ 'stop')
+ asterisk_stop
+ ;;
+ 'restart')
+ asterisk_restart
+ ;;
+ *)
+ echo "usage $0 start|stop|restart" ;;
+esac
+
diff --git a/trunk/contrib/init.d/rc.suse.asterisk b/trunk/contrib/init.d/rc.suse.asterisk
new file mode 100755
index 000000000..3eb1be55f
--- /dev/null
+++ b/trunk/contrib/init.d/rc.suse.asterisk
@@ -0,0 +1,127 @@
+#!/bin/sh
+# $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
+# 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
+# - Verified SIGTERM issued by "killproc" ensures "stop gracefully"
+# - Added support for -U and -G command line options
+# - Modified "reload" to call asterisk -rx 'reload'
+
+### BEGIN INIT INFO
+# Provides: asterisk
+# Required-Start: +zaptel
+# Required-Stop:
+# Default-Start: 3 5
+# Default-Stop: 0 1 2 4 6
+# Description: zaptel - zaptel modules for Asterisk
+### END INIT INFO
+
+# Source function library.
+. /lib/lsb/init-functions
+
+if ! [ -x /usr/sbin/asterisk ] ; then
+ echo "ERROR: /usr/sbin/asterisk not found"
+ exit 0
+fi
+
+if ! [ -d /etc/asterisk ] ; then
+ echo "ERROR: /etc/asterisk 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=/usr/sbin/asterisk
+
+# Full path to safe_asterisk script
+SAFE_ASTERISK=/usr/sbin/safe_asterisk
+
+# Uncomment the following and set them to the user/groups that you
+# want to run Asterisk as. NOTE: this requires substantial work to
+# be sure that Asterisk's environment has permission to write the
+# files required for its operation, including logs, its comm
+# socket, the asterisk database, etc.
+#AST_USER="asterisk"
+#AST_GROUP="asterisk"
+
+RETVAL=0
+
+start() {
+ # Start daemons.
+ echo -n $"Starting asterisk: "
+ if [ -f $SAFE_ASTERISK ] ; then
+ DAEMON=$SAFE_ASTERISK
+ fi
+ if [ $AST_USER ] ; then
+ ASTARGS="-U $AST_USER"
+ fi
+ if [ $AST_GROUP ] ; then
+ ASTARGS="`echo $ASTARGS` -G $AST_GROUP"
+ fi
+ $DAEMON $ASTARGS
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/asterisk
+ echo
+ return $RETVAL
+}
+
+stop() {
+ # Stop daemons.
+ echo -n $"Shutting down asterisk: "
+ killproc asterisk
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/asterisk
+ echo
+ return $RETVAL
+}
+
+restart() {
+ stop
+ start
+}
+
+reload() {
+ $DAEMON -rx 'reload' > /dev/null 2> /dev/null
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ restart
+ ;;
+ reload)
+ reload
+ ;;
+ condrestart)
+ [ -f /var/lock/subsys/asterisk ] && restart || :
+ ;;
+ status)
+ status asterisk
+ ;;
+ *)
+ echo "Usage: asterisk {start|stop|restart|reload|condrestart|status}"
+ exit 1
+esac
+
+exit $?