#! /bin/sh # # lcr start LCR # This package is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Based on: # # skeleton example file to build /etc/init.d/ scripts. # This file should be used to construct scripts for /etc/init.d. # # Written by Miquel van Smoorenburg . # Modified for Debian GNU/Linux # by Ian Murdock . # # Version: @(#)skeleton 1.9 26-Feb-2001 miquels@cistron.nl # ### BEGIN INIT INFO # Provides: lcr # Required-Start: $local_fs # Required-Stop: $local_fs # Should-Start: # Should-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: LCR # Description: Controls LCR ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin NAME=lcr USER=asterisk GROUP=asterisk DAEMON=/usr/sbin/$NAME DESC="LCR" PIDFILE="/var/run/lcr/lcr.pid" PIDFILE_DIR=`dirname $PIDFILE` UMASK=007 # by default #MAXFILES=1024 # (the system default) PARAMS="start" CHDIR_PARM="" if [ -r /etc/default/$NAME ]; then . /etc/default/$NAME; fi if [ "x$USER" = "x" ] then echo "Error: empty USER name" exit 1 fi if [ `id -u "$USER"` = 0 ] then echo "Starting as root not supported." exit 1 fi test -x $DAEMON || exit 0 if [ ! -d "$PIDFILE_DIR" ];then mkdir "$PIDFILE_DIR" chown $USER:$GROUP "$PIDFILE_DIR" fi set -e if [ "$UMASK" != '' ] then umask $UMASK fi # allow changing the per-process open files limit: if [ "$MAXFILES" != '' ] then ulimit -n $MAXFILES fi status() { plist=`ps ax | awk "{ if (\\$5 == \"$DAEMON\") print \\$1 }"` if [ "$plist" = "" ]; then echo "$DESC is stopped" return 1 else echo "$DESC is running: $plist" return 0 fi } case "$1" in start) if status > /dev/null; then echo "$DESC is already running. Use restart." exit 0 fi echo -n "Starting $DESC: " start-stop-daemon --start --chuid $USER:$GROUP \ --background --make-pidfile \ $CHDIR_PARM --pidfile "$PIDFILE" \ --exec $DAEMON -- $PARAMS echo "$NAME." ;; stop) echo -n "Stopping $DESC: $NAME" # No bother to worry about cleanup: # it will either fail or die when asterisk dies. # just making sure it's really, really dead. # KILL is necessary just in case there's an asterisk -r in the background start-stop-daemon --stop --quiet --oknodo --retry=0/2/TERM/2/KILL/5 --exec $DAEMON echo "." ;; reload) $DAEMON interface $DAEMON route ;; restart|force-reload) $0 stop $0 start ;; status) status exit $? ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|reload|status|debug|logger-reload|extensions-reload|restart-convenient|force-reload}" >&2 exit 1 ;; esac exit 0