#!/bin/sh
set -e

MSGBROKER_BIN="/usr/bin/BaSS_MsgBroker_d"
MSGBROKER_OPTS=""

# include init functions
source /etc/init.d/functions

case "$1" in
  start)
      echo -n "Starting BaSS MsgBroker: "
      start-stop-daemon -S -b -x $MSGBROKER_BIN -- $MSGBROKER_OPTS
      echo "done."
      ;;
  stop)
      echo -n "Stopping BaSS MsgBroker: "
      start-stop-daemon -K -R1 -x $MSGBROKER_BIN
      echo "."
      ;;
  restart)
      echo -n "Restarting BaSS MsgBroker: "
      start-stop-daemon -K -R1 --oknodo -x $MSGBROKER_BIN
      sleep 2
      start-stop-daemon -S -b -x $MSGBROKER_BIN -- $MSGBROKER_OPTS
      echo "."
      ;;
  status)
      status $MSGBROKER_BIN
      exit $?
      ;;
  *)
      echo "Usage: /etc/init.d/msgbroker {start|stop|restart|status}"
      exit 1
esac

exit 0
