219
224
# 1 if daemon was already stopped
220
225
# 2 if daemon could not be stopped
221
226
# other if a failure occurred
222
start-stop-daemon --stop --quiet --retry=QUIT/30/KILL/5 --pidfile $TC_PIDFILE --name $TC_NAME
224
test "$RETVAL" != 0 && return 2
227
start-stop-daemon --stop --quiet --retry=QUIT/30/KILL/5 --pidfile $TC_PIDFILE --name $TC_NAME
229
test "$RETVAL" != 0 && return 2
225
230
# Wait for children to finish too if this is a daemon that forks
226
231
# and if the daemon is only ever run from this initscript.
227
232
# If the above conditions are not satisfied then add some other code
228
233
# that waits for the process to drop all resources that could be
229
234
# needed by services started subsequently. A last resort is to
230
235
# sleep for some time.
231
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $TC_DAEMON
232
test "$?" != 0 && return 2
236
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $TC_DAEMON
237
test "$?" != 0 && return 2
233
238
# Need to stop the TM and TS also
234
start-stop-daemon --stop --quiet --retry=QUIT/30/KILL/5 --pidfile $TM_PIDFILE --name $TM_NAME
235
test "$?" != 0 && return 2
236
start-stop-daemon --stop --quiet --retry=QUIT/30/KILL/5 --pidfile $TS_PIDFILE --name $TS_NAME
237
test "$?" != 0 && return 2
239
start-stop-daemon --stop --quiet --retry=QUIT/30/KILL/5 --pidfile $TM_PIDFILE --name $TM_NAME
240
test "$?" != 0 && return 2
241
start-stop-daemon --stop --quiet --retry=QUIT/30/KILL/5 --pidfile $TS_PIDFILE --name $TS_NAME
242
test "$?" != 0 && return 2
238
243
# Many daemons don't delete their pidfiles when they exit.
246
# Ubuntu: Function that sends a SIGHUP to the daemon/service
251
# If the daemon can reload its configuration without
252
# restarting (for example, when it is sent a SIGHUP),
253
# then implement that here.
255
start-stop-daemon --stop --signal 1 --quiet --pidfile $TS_PIDFILE --name $TS_NAME
264
if [ "$DISTRIB_ID" = "ubuntu" -o "$DISTRIB_ID" = "debian" ] ; then
265
test "x$VERBOSE" != "xno" && log_daemon_msg "Starting $DESC" "$NAME"
268
test "$?" -ne 0 -a "$?" -ne 1 && retval=1
269
test "x$VERBOSE" != "xno" && log_daemon_msg "$retval"
271
elif [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
272
action "Starting ${TS_PACKAGE_NAME}:" forkdaemon $TC_DAEMON $TC_DAEMON_ARGS
273
elif [ "$DISTRIB_ID" = "suse" ]; then
274
echo -n "Starting ${TS_PACKAGE_NAME}"
275
startproc -p $TC_PIDFILE $TC_DAEMON $TC_DAEMON_ARGS
277
elif [ "$DISTRIB_ID" = "Darwin" ]; then
278
echo "Starting ${TS_PACKAGE_NAME}"
279
launchctl list $TC_NAME > /dev/null 2>&1 && exit 0
280
launchctl submit -l $TC_NAME -p $TC_DAEMON -o $STDOUTLOG -e $STDERRLOG -- $TC_DAEMON_ARGS
281
elif [ "$DISTRIB_ID" = "FreeBSD" ]; then
282
echo "Starting ${TS_PACKAGE_NAME}"
284
command="/usr/sbin/daemon"
285
command_args="$TC_DAEMON $TC_DAEMON_ARGS"
286
pidfile="$TC_PIDFILE"
289
echo "This script needs to be ported to this OS"
294
if [ "$DISTRIB_ID" = "ubuntu" -o "$DISTRIB_ID" = "debian" ] ; then
295
test "x$VERBOSE" != "xno" && log_daemon_msg "Stopping $DESC" "$NAME"
298
test "$?" -ne 0 -a "$?" -ne 1 && retval=1
299
test "x$VERBOSE" != "xno" && log_daemon_msg "$retval"
301
elif [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
302
action "Stopping ${TC_NAME}:" killproc -p $TC_PIDFILE $TC_DAEMON
303
action "Stopping ${TM_NAME}:" killproc -p $TM_PIDFILE $TM_DAEMON
304
action "Stopping ${TS_NAME}:" killproc -p $TS_PIDFILE $TS_DAEMON
305
elif [ "$DISTRIB_ID" = "suse" ]; then
306
echo -n "Stopping ${TC_NAME}"
307
killproc -p $TC_PIDFILE $TC_DAEMON
309
echo -n "Stopping ${TM_NAME}"
310
killproc -p $TM_PIDFILE $TM_DAEMON
312
echo -n "Stopping ${TS_NAME}"
313
killproc -p $TS_PIDFILE $TS_DAEMON
315
elif [ "$DISTRIB_ID" = "Darwin" ]; then
316
echo "Stopping ${TS_PACKAGE_NAME}"
317
launchctl list $TC_NAME > /dev/null 2>&1 || exit 0
318
echo "Stopping ${TC_NAME}"
319
launchctl remove ${TC_NAME}
321
echo "Stopping ${TM_NAME}"
322
kill $(cat $TM_PIDFILE)
324
echo "Stopping ${TS_NAME}"
325
kill $(cat $TS_PIDFILE)
327
elif [ "$DISTRIB_ID" = "FreeBSD" ]; then
328
echo "Stopping ${TS_PACKAGE_NAME}"
329
if [ -e "$TC_PIDFILE" ]; then
330
kill $(cat $TC_PIDFILE)
333
if [ -e "$TM_PIDFILE" ]; then
334
kill $(cat $TM_PIDFILE)
338
echo "This script needs to be ported to this OS"
342
#reload|force-reload)
344
# If do_reload() is not implemented then leave this commented out
345
# and leave 'force-reload' as an alias for 'restart'.
347
#log_daemon_msg "Reloading $DESC" "$NAME"
351
restart|force-reload)
352
if [ "$DISTRIB_ID" = "ubuntu" -o "$DISTRIB_ID" = "debian" ] ; then
253
if [ "$DISTRIB_ID" = "ubuntu" -o "$DISTRIB_ID" = "debian" ] ; then
254
test "x$VERBOSE" != "xno" && log_daemon_msg "Starting $DESC" "$NAME"
257
test "$?" -ne 0 -a "$?" -ne 1 && retval=1
258
test "x$VERBOSE" != "xno" && log_daemon_msg "$retval"
260
elif [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
261
action "Starting ${TS_PACKAGE_NAME}:" forkdaemon $TC_DAEMON $TC_DAEMON_ARGS
262
elif [ "$DISTRIB_ID" = "suse" ]; then
263
echo -n "Starting ${TS_PACKAGE_NAME}"
264
startproc -p $TC_PIDFILE $TC_DAEMON $TC_DAEMON_ARGS
266
elif [ "$DISTRIB_ID" = "Darwin" ]; then
267
echo "Starting ${TS_PACKAGE_NAME}"
268
launchctl list $TC_NAME > /dev/null 2>&1 && exit 0
269
launchctl submit -l $TC_NAME -p $TC_DAEMON -o $STDOUTLOG -e $STDERRLOG -- $TC_DAEMON_ARGS
270
elif [ "$DISTRIB_ID" = "FreeBSD" ]; then
271
echo "Starting ${TS_PACKAGE_NAME}"
273
command="/usr/sbin/daemon"
274
command_args="$TC_DAEMON $TC_DAEMON_ARGS"
275
pidfile="$TC_PIDFILE"
278
echo "This script needs to be ported to this OS"
283
if [ "$DISTRIB_ID" = "ubuntu" -o "$DISTRIB_ID" = "debian" ] ; then
284
test "x$VERBOSE" != "xno" && log_daemon_msg "Stopping $DESC" "$NAME"
287
test "$?" -ne 0 -a "$?" -ne 1 && retval=1
288
test "x$VERBOSE" != "xno" && log_daemon_msg "$retval"
290
elif [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
291
action "Stopping ${TC_NAME}:" killproc -p $TC_PIDFILE $TC_DAEMON
292
action "Stopping ${TM_NAME}:" killproc -p $TM_PIDFILE $TM_DAEMON
293
action "Stopping ${TS_NAME}:" killproc -p $TS_PIDFILE $TS_DAEMON
294
elif [ "$DISTRIB_ID" = "suse" ]; then
295
echo -n "Stopping ${TC_NAME}"
296
killproc -p $TC_PIDFILE $TC_DAEMON
298
echo -n "Stopping ${TM_NAME}"
299
killproc -p $TM_PIDFILE $TM_DAEMON
301
echo -n "Stopping ${TS_NAME}"
302
killproc -p $TS_PIDFILE $TS_DAEMON
304
elif [ "$DISTRIB_ID" = "Darwin" ]; then
305
echo "Stopping ${TS_PACKAGE_NAME}"
306
launchctl list $TC_NAME > /dev/null 2>&1 || exit 0
307
echo "Stopping ${TC_NAME}"
308
launchctl remove ${TC_NAME}
310
echo "Stopping ${TM_NAME}"
311
kill $(cat $TM_PIDFILE)
313
echo "Stopping ${TS_NAME}"
314
kill $(cat $TS_PIDFILE)
316
elif [ "$DISTRIB_ID" = "FreeBSD" ]; then
317
echo "Stopping ${TS_PACKAGE_NAME}"
318
if [ -e "$TC_PIDFILE" ]; then
319
kill $(cat $TC_PIDFILE)
322
if [ -e "$TM_PIDFILE" ]; then
323
kill $(cat $TM_PIDFILE)
327
echo "This script needs to be ported to this OS"
332
if [ "$DISTRIB_ID" = "ubuntu" -o "$DISTRIB_ID" = "debian" ] ; then
333
test "x$VERBOSE" != "xno" && log_daemon_msg "Reloading ${NAME}:"
336
test "$?" -ne 0 -a "$?" -ne 1 && retval=1
337
test "x$VERBOSE" != "xno" && log_daemon_msg "$retval"
339
elif [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
340
action "Reloading ${NAME}:" $TL_NAME -x
341
elif [ "$DISTRIB_ID" = "suse" ]; then
342
echo -n "Reloading ${NAME}"
345
elif [ "$DISTRIB_ID" = "Darwin" ]; then
346
echo "Reloading ${NAME}"
348
elif [ "$DISTRIB_ID" = "FreeBSD" ]; then
349
echo "Reloading ${NAME}"
352
echo "This script needs to be ported to this OS"
357
if [ "$DISTRIB_ID" = "ubuntu" -o "$DISTRIB_ID" = "debian" ] ; then
354
359
# If the "reload" option is implemented then remove the
355
360
# 'force-reload' alias
357
log_daemon_msg "Restarting $DESC" "$NAME"
362
log_daemon_msg "Restarting $DESC" "$NAME"
364
1) log_end_msg 1 ;; # Old process is still running
365
*) log_end_msg 1 ;; # Failed to start
370
1) log_end_msg 1 ;; # Old process is still running
371
*) log_end_msg 1 ;; # Failed to start
374
380
# This is the typical process for restart
380
if [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
381
status -p $TC_PIDFILE $TC_NAME
382
elif [ "$DISTRIB_ID" = "suse" ]; then
383
echo -n "Checking for service ${DM}: "
384
checkproc -p $TC_PIDFILE $TC_NAME
386
elif [ "$DISTRIB_ID" = "Darwin" ]; then
387
/bin/echo -n "${TS_PACKAGE_NAME} is "
388
launchctl list $TC_NAME > /dev/null 2>&1
390
[ $status -eq 0 ] || /bin/echo -n "not "
392
elif [ "$DISTRIB_ID" = "FreeBSD" ]; then
393
if pgrep $TM_NAME > /dev/null ; then
394
echo "$TM_NAME running as pid `cat $TM_PIDFILE`" ; else
395
echo "$TM_NAME not running"
397
if pgrep $TS_NAME > /dev/null ; then
398
echo "$TS_NAME running as pid `cat $TS_PIDFILE`"; else
399
echo "$TS_NAME not running"
401
if pgrep $TC_NAME > /dev/null ; then
402
echo "$TC_NAME running as pid `cat $TC_PIDFILE`"; else
403
echo "$TC_NAME not running" ;
407
echo "This script needs to be ported to this OS"
412
if [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
419
echo "This script needs to be ported to this OS"
424
if [ "$DISTRIB_ID" = "ubuntu" -o "$DISTRIB_ID" = "debian" ] ; then
425
echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
426
elif [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
427
echo "Usage: $0 {start|stop|status|restart|condrestart}"
428
elif [ "$DISTRIB_ID" = "suse" ]; then
429
echo "Usage: $0 {start|stop|restart|status}"
430
elif [ "$DISTRIB_ID" = "Darwin" ]; then
431
echo "Usage: $0 {start|stop|restart|status}"
432
elif [ "$DISTRIB_ID" = "FreeBSD" ]; then
433
echo "Usage: $0 Usage: (start|stop|restart|status)"
434
echo "NB: FreeBSD's ports system installs a rc script in"
435
echo "/usr/local/etc/rc.d/ with native rc.subr(8) features."
437
echo "This script needs to be ported to this OS"
387
if [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
388
status -p $TC_PIDFILE $TC_NAME
389
elif [ "$DISTRIB_ID" = "suse" ]; then
390
echo -n "Checking for service ${DM}: "
391
checkproc -p $TC_PIDFILE $TC_NAME
393
elif [ "$DISTRIB_ID" = "Darwin" ]; then
394
/bin/echo -n "${TS_PACKAGE_NAME} is "
395
launchctl list $TC_NAME > /dev/null 2>&1
397
[ $status -eq 0 ] || /bin/echo -n "not "
399
elif [ "$DISTRIB_ID" = "FreeBSD" ]; then
400
if pgrep $TM_NAME > /dev/null ; then
401
echo "$TM_NAME running as pid `cat $TM_PIDFILE`" ; else
402
echo "$TM_NAME not running"
404
if pgrep $TS_NAME > /dev/null ; then
405
echo "$TS_NAME running as pid `cat $TS_PIDFILE`"; else
406
echo "$TS_NAME not running"
408
if pgrep $TC_NAME > /dev/null ; then
409
echo "$TC_NAME running as pid `cat $TC_PIDFILE`"; else
410
echo "$TC_NAME not running" ;
414
echo "This script needs to be ported to this OS"
419
if [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
426
echo "This script needs to be ported to this OS"
431
if [ "$DISTRIB_ID" = "ubuntu" -o "$DISTRIB_ID" = "debian" ] ; then
432
echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
433
elif [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
434
echo "Usage: $0 {start|stop|status|restart|condrestart}"
435
elif [ "$DISTRIB_ID" = "suse" ]; then
436
echo "Usage: $0 {start|stop|restart|status}"
437
elif [ "$DISTRIB_ID" = "Darwin" ]; then
438
echo "Usage: $0 {start|stop|restart|status}"
439
elif [ "$DISTRIB_ID" = "FreeBSD" ]; then
440
echo "Usage: $0 Usage: (start|stop|restart|status)"
441
echo "NB: FreeBSD's ports system installs a rc script in"
442
echo "/usr/local/etc/rc.d/ with native rc.subr(8) features."
444
echo "This script needs to be ported to this OS"