#!/bin/sh

###############################################################################
###############################################################################


readonly DAEMON="/usr/local/sbin/myles"


# Indicate whether reloads are supported via signals (usually SIGHUP (1)).
# If so, define RELOAD_SIGNAL to the signal. If not, comment out.
#RELOAD_SIGNAL="1"

# Include the common script for all service scripts.
source /etc/init.d/rcservices

export LD_LIBRARY_PATH=/usr/local/lib

#------------------------------------------------------------------------------
# Start the service.
do_start ()
{
  echo -n "Starting $(basename $DAEMON) daemon "
  start-stop-daemon --background --quiet --start --exec $DAEMON
  case $? in
    0) RESULT=$SUCCESS;;             # Started OK
    1) RESULT=$PROGRAM_IS_RUNNING;;  # Already running
    *) RESULT=$FAILED;;              # Trouble
  esac
  print_result
  return $RESULT
}

#------------------------------------------------------------------------------
# Stop the service.
do_stop ()
{
  echo -n "Stopping $DAEMON daemon "
  start-stop-daemon --quiet --stop --exec $DAEMON

  case $? in
    0) RESULT=$SUCCESS;;              # Stopped OK
    1) RESULT=$PROGRAM_NOT_RUNNING;;  # No process running
    *) RESULT=$FAILED;;               # Trouble
  esac
  print_result
  return $RESULT
}

# Do the service.
dispatch_service $1
