3 # lcr start the lcr isdn PBX
4 # (c) Joerg Dorchain <joerg@dorchain.net>
6 # This package is free software; you can redistribute it and/or
8 # it under the terms of the GNU General Public License as
10 # the Free Software Foundation; either version 2 of the
12 # (at your option) any later version.
16 # skeleton example file to build /etc/init.d/ scripts.
17 # This file should be used to construct scripts for
20 # Written by Miquel van Smoorenburg
21 # <miquels@cistron.nl>.
22 # Modified for Debian GNU/Linux
23 # by Ian Murdock <imurdock@gnu.ai.mit.edu>.
25 # Version: @(#)skeleton 1.9 26-Feb-2001
31 # Required-Start: $remote_fs
32 # Required-Stop: $remote_fs
33 # Default-Start: 2 3 4 5
35 # Short-Description: lcr PBX
36 # Description: Controls the Linux Call Router ISDN PBX
39 # PATH should only include /usr/* if it runs after the mountnfs.sh script
40 PATH=/sbin:/usr/sbin:/bin:/usr/bin
43 DAEMON=/usr/sbin/$NAME
45 PIDFILE=/var/run/$NAME.pid
46 SCRIPTNAME=/etc/init.d/$NAME
50 # Exit if the package is not installed
51 [ -x "$DAEMON" ] || exit 0
53 # Read configuration variable file if it is present
54 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
56 if [ "$RUNLCR" != "yes" ];then
57 echo "lcr not yet configured. Edit /etc/default/lcr first."
61 # Load the VERBOSE setting and other rcS variables
64 # Define LSB log_* functions.
65 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
66 . /lib/lsb/init-functions
69 plist=`ps ax | awk "{ if (\\$5 == \"$DAEMON\") print \\$1
71 if [ "$plist" = "" ]; then
72 echo "$DESC is stopped"
75 echo "$DESC is running: $plist"
81 # Function that starts the daemon/service
86 # 0 if daemon has been started
87 # 1 if daemon was already running
88 # 2 if daemon could not be started
89 if status > /dev/null; then
90 echo "$DESC is already running. Use restart."
94 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
96 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
99 # Add code here, if necessary, that waits for the process to be ready
100 # to handle requests from services started subsequently which depend
101 # on this one. As a last resort, sleep for some time.
105 # Function that stops the daemon/service
110 # 0 if daemon has been stopped
111 # 1 if daemon was already stopped
112 # 2 if daemon could not be stopped
113 # other if a failure occurred
114 start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
116 [ "$RETVAL" = 2 ] && return 2
117 # Wait for children to finish too if this is a daemon that forks
118 # and if the daemon is only ever run from this initscript.
119 # If the above conditions are not satisfied then add some other code
120 # that waits for the process to drop all resources that could be
121 # needed by services started subsequently. A last resort is to
122 # sleep for some time.
123 start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
124 [ "$?" = 2 ] && return 2
125 # Many daemons don't delete their pidfiles when they exit.
131 # Function that sends a SIGHUP to the daemon/service
135 # If the daemon can reload its configuration without
136 # restarting (for example, when it is sent a SIGHUP),
137 # then implement that here.
139 #start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
147 [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
150 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
151 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
155 [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
158 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
159 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
164 # If do_reload() is not implemented then leave this commented out
165 # and leave 'force-reload' as an alias for 'restart'.
167 log_daemon_msg "Reloading $DESC" "$NAME"
174 restart|force-reload)
176 # If the "reload" option is implemented then remove the
177 # 'force-reload' alias
179 log_daemon_msg "Restarting $DESC" "$NAME"
186 1) log_end_msg 1 ;; # Old process is still running
187 *) log_end_msg 1 ;; # Failed to start
197 #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
198 echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2