#! /bin/sh
### BEGIN INIT INFO
# Provides:          comb_bt
# Required-Start:    $local_fs $network $remote_fs $time $bluetooth
# Required-Stop:     $local_fs $network $remote_fs $time $bluetooth
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Comb BT Loader tool
# Description:       Comb BT Loader tool
### END INIT INFO
#
# Author:       Ryan Murray <rmurray@debian.org>
#

PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/comb/bin
DAEMON=/opt/comb/bin/comb_bt
PIDFILE=/run/lock/comb_bt

test -x $DAEMON || exit 0

if [ -e /lib/lsb/init-functions ];then
	. /lib/lsb/init-functions
    elif [ -e /etc/init.d/functions ];then
	. /etc/init.d/functions
fi

case "$1" in
  start)
	if [ -e /lib/lsb/init-functions ];then
		log_daemon_msg "Starting deferred execution scheduler" "comb_bt"
		start_daemon -p $PIDFILE $DAEMON -d
		log_end_msg $?
	   elif [ -e /etc/init.d/functions ];then
		echo -n "Starting comb_bt: "
		start-stop-daemon --start -p $PIDFILE $DAEMON -- -d && echo "OK"
	fi;
	;;
  stop)
	if [ -e /lib/lsb/init-functions ];then
		log_daemon_msg "Stopping deferred execution scheduler" "comb_bt"
		killproc -p $PIDFILE $DAEMON
		log_end_msg $?
	   elif [ -e /etc/init.d/functions ];then
		echo -n "Stopping comb_bt: "
		start-stop-daemon --stop -p $PIDFILE $DAEMON
	fi;
	;;
  force-reload|restart)
	$0 stop
	$0 start
	;;
  status)
	if [ -e /lib/lsb/init-functions ];then
		status_of_proc -p $PIDFILE $DAEMON comb_bt && exit 0 || exit $?
	   elif [ -e /etc/init.d/functions ];then
		status comb_bt && exit 0 || exit $?
	fi;
	;;
  *)
    echo "Usage: /etc/init.d/comb_bt {start|stop|restart|force-reload|status}"
    exit 1
    ;;
esac

exit 0
