#!/bin/sh
set -e

SYSTEMCONTROL_BIN="/usr/bin/SystemControl_d"
SYSTEMCONTROL_OPTS=""

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

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

exit 0
