#! /bin/sh
# /etc/init.d/scandetd: start/stop scandetd portscan detector.

PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/usr/sbin/scandetd
PIDFILE=/var/run/scandetd.pid

test -f /usr/sbin/scandetd || exit 0
test -f /etc/scandetd.conf || exit 0

case $1 in
  start)
    echo -n "Starting portscan detector: scandetd"
    start-stop-daemon --start --quiet --make-pidfile --pidfile $PIDFILE --exec $DAEMON
  echo "."
  ;;
  stop)
    echo -n "Stopping portscan detector: scandetd"
    start-stop-daemon --stop --quiet --pidfile $PIDFILE
    rm $PIDFILE
    echo "."
  ;;
  restart)
    $0 stop
    $0 start
  ;;
  reload|force-reload)
    echo -n "Reloading scandetd configuration file..."
    start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --exec $DAEMON
    echo "."
  ;;
  status)
    if [ -f $PIDFILE ] ; then
      echo "scandetd (pid `cat $PIDFILE`) is running..."
    else
      echo "scandetd is not running."
    fi
  ;;
  *)
    echo "Usage: /etc/init.d/scandetd {start|stop|restart|reload|force-reload|status}"
    exit 1
  ;;
esac
exit 0
