#!/bin/sh

###############################################################################
#
# /etc/init.d/xinetd - System control script for the xinetd daemon.
# Also accessed via a symbolic link named /usr/local/sbin/rcxinetd.
#
# Copyright (c) 2006, all rights reserved
# License- GPL
# Author-  Andre G Ancelin
# Company- Adtec Digital, Inc.
# Date-    2006-04-05
#
###############################################################################

readonly DAEMON="/usr/sbin/xinetd"

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

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

#------------------------------------------------------------------------------
# Start the service.
do_start ()
{
  # Start the daemon.
  echo -n "Starting $DAEMON daemon "
  start-stop-daemon --quiet --start --exec $DAEMON -- -f /etc/xinetd.d/xinetd.conf
  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 ()
{
  # Stop the service.
  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
