#!/bin/sh

PATH=/bin:/usr/bin:/sbin:/usr/sbin

PROGRAMFILE=/home/kdxuser/kdxservfolder/KDXServer.lexe
PIDFILE=/var/run/KDXServer.pid

# Parameters to pass to KDXServer.
# The nohup option means it will not exit when disconnected from the terminal.
PARAMS="--nohup"

# Check that the program file exists and is executable
test -x $PROGRAMFILE || exit 0

case "$1" in
  start)
    echo -n "Starting Haxial KDX Server"
    start-stop-daemon --start --background --pidfile $PIDFILE --exec $PROGRAMFILE -- $PARAMS
    echo "."
    ;;
  stop)
    echo -n "Stopping Haxial KDX Server"
    start-stop-daemon --stop --background --pidfile $PIDFILE --exec $PROGRAMFILE
    echo "."
    ;;
  reload)
    echo "Not implemented."
    ;;
  force-reload|restart)
    sh $0 stop
    sh $0 start
    ;;
  *)
    echo "Usage: file.sh {start|stop|restart|force-reload|reload}"
    exit 1
    ;;
esac

exit 0