#! /bin/sh
#
# init.d/scanlogd
#
#   and symbolic its link
#
# /usr/sbin/rcscanlogd
#
# System startup script for the scanlogd
#
### BEGIN INIT INFO
# Provides: scanlogd
# Required-Start: $network
# Should-Start: $syslog
# Should-Stop: $null
# Required-Stop: $null
# Default-Start:  3 5
# Default-Stop:   0 1 2 6
# Short-Description: scanlogd detects and logs TCP port scans.
# Description:  scanlogd detects and logs TCP port scans.
### END INIT INFO

# Source SuSE config
. /etc/rc.status

SLD_BIN=/usr/sbin/scanlogd
SLD_PID=/var/run/scanlogd/scanlogd.pid
test -x $SLD_BIN || { echo "$SLD_BIN not installed";
    if [ "$1" = "stop" ]; then exit 0; else exit 5; fi; }

SLD_PID=/var/run/scanlogd/scanlogd.pid

# Shell functions sourced from /etc/rc.status:
#      rc_check         check and set local and overall rc status
#      rc_status        check and set local and overall rc status
#      rc_status -v     ditto but be verbose in local rc status
#      rc_status -v -r  ditto and clear the local rc status
#      rc_failed        set local and overall rc status to failed
#      rc_reset         clear local rc status (overall remains)
#      rc_exit          exit appropriate to overall rc status

# First reset status of this service
rc_reset

# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - misc error
# 2 - invalid or excess args
# 3 - unimplemented feature (e.g. reload)
# 4 - insufficient privilege
# 5 - program not installed
# 6 - program not configured
#

case "$1" in
    start)
	echo -n "Starting Scanlogd"
	# /var/run might be on tmpfs
	[ -d /var/run/scanlogd ] || mkdir /var/run/scanlogd
	 startproc $SLD_BIN

	rc_status -v
	;;
    stop)
	echo -n "Shutting down Scanlogd"
	/sbin/killproc -TERM $SLD_BIN
	rc_status -v
	;;
    restart)
	## Stop the service and regardless of whether it was
	## running or not, start it again.
	$0 stop
	$0 start
	rc_status
	;;
    status)
	echo -n "Checking for Scanlogd "
	/sbin/checkproc $SLD_BIN
	rc_status -v
	;;
    *)
	echo "Usage: $0 {start|stop|status|restart}"
	exit 1
	;;
esac
rc_exit
