You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iaxmodem/debian/ngcp-iaxmodem.init

91 lines
2.1 KiB

#! /bin/bash
### BEGIN INIT INFO
# Provides: ngcp-iaxmodem
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Ngcp iaxmodem
# Description: A software modem with IAX support.
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
NAME=ngcp-iaxmodem
DESC="iaxmodem"
RUN_IAXMODEM=no
case $(dirname $0) in
/*) FULLPATH=$(dirname $0);;
*) FULLPATH=$(pwd)/$(dirname $0);;
esac
DAEMON=`which ngcp-iaxmodem`
DEFAULTS=/etc/default/ngcp-iaxmodem
test -f $DAEMON || exit 0
# Load startup options if available
if [ -f $DEFAULTS ]; then
. $DEFAULTS || true
fi
PIDFILE="/var/run/iaxmodem.pid"
set -e
. /lib/lsb/init-functions
function check_run {
if [ "$RUN_IAXMODEM" != "yes" ]; then
echo "ngcp-iaxmodem configured to not run. Set RUN_IAXMODEM to 'yes' in $DEFAULTS first."
exit 0
fi
}
case "$1" in
start)
check_run
echo -n "Starting $DESC: $NAME"
start-stop-daemon --start --quiet --oknodo \
--pidfile $PIDFILE \
--exec $DAEMON -- $OPTIONS || echo -n " already running"
log_end_msg $?
;;
stop)
echo -n "Stopping $DESC: $NAME"
start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \
--exec $DAEMON
if [ "$?" -ne 0 ]; then
return $?
fi
rm -f $PIDFILE
log_end_msg $?
;;
restart|force-reload)
check_run
echo -n "Restarting $DESC: $NAME"
start-stop-daemon --oknodo --stop --quiet --pidfile \
$PIDFILE --exec $DAEMON
if [ "$?" -ne 0 ]; then
return $?
fi
rm -f $PIDFILE
sleep 1
start-stop-daemon --start --quiet \
--pidfile $PIDFILE \
--exec $DAEMON -- $OPTIONS
log_end_msg $?
;;
status)
status_of_proc -p $PIDFILE "$DAEMON" "$NAME" && exit 0 || exit $?
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload|status}" >&2
exit 1
;;
esac
exit 0