#!/bin/sh
#
# honeyd	This shell script takes care of starting and stopping honeyd.
#
# chkconfig: 345 55 45
# description: honeyd is a virtual honeypot daemon.
# probe: false
# processname: honeyd
# pidfile: /var/run/honeyd.pid
# config: /etc/honeyd.conf
# config: /etc/sysconfig/honeyd

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0

[ -f /etc/honeyd.conf ] || exit 0

[ -f /usr/sbin/honeyd ] || exit 0

[ -f /etc/sysconfig/honeyd ] && . /etc/sysconfig/honeyd

# See how we were called.
case "$1" in
start)
	gprintf "Starting honeyd: "
	OPTION="";

	if [ -n "$INTERFACE" ]; then
		OPTION="-i ${INTERFACE}";
	fi;

	if [ -n "$IP" ]; then
		OPTION="${OPTION} ${IP}";
	fi;	
	cd /usr/share/honeyd
	/usr/sbin/honeyd -p ./nmap.prints \
	-f /etc/honeyd.conf -x ./xprobe2.conf \
	-a ./nmap.assoc -l /var/log/honeyd.log \
	$OPTION
	echo
	touch /var/lock/subsys/honeyd
	;;
stop)
	gprintf "Stopping honeyd: "
	killproc honeyd
	echo
	rm -f /var/lock/subsys/honeyd
	;;
status)
	status honeyd
	;;
restart|reload)
	$0 stop
	$0 start
	;;
condrestart)
	[ -f /var/lock/subsys/honeyd ] && restart
	;;
  *)
	gprintf "Usage: honeyd {start|stop|status|restart|condrestart|reload}\n"
	exit 1
esac

exit 0
