#! /bin/sh
#
# skeleton	example file to build /etc/init.d/ scripts.
#		This file should be used to construct scripts for /etc/init.d.
#
#		Written by Miquel van Smoorenburg <miquels@cistron.nl>.
#		Modified for Debian 
#		by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
# Version:	@(#)skeleton  1.9  26-Feb-2001  miquels@cistron.nl
#

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/ipkungfu
NAME=ipkungfu
DESC=ipkungfu
LOGFILE=/var/log/ipkungfu.log

test -x $DAEMON || exit 0

ipkf_configerr () {
	echo -n "Not Starting/Stopping $DESC: Please read /usr/share/doc/ipkungfu/README.Debian for details"
	exit 0
}

# the user must change /etc/default/ipkungfu (as per recommendation in Bug#315074).
if [ -f "/etc/default/ipkungfu" ]
then
        . /etc/default/ipkungfu
        if [ "$IPKFSTART" != "1" ]
        then
                ipkf_configerr
        fi
fi


set -e

case "$1" in
  start|reload|force-reload)
	#In IPKungfu reload and start are the same things...
	echo -n "Starting $DESC: "
	if $DAEMON 2>&1 >>$LOGFILE ; then
		echo "$NAME."
	else
		echo "Failed - check $LOGFILE for details."
	fi
	;;
  stop)
	echo -n "Stopping $DESC: "
	if $DAEMON -d 2>&1 >>$LOGFILE ; then
                echo "$NAME."
        else
                echo "Failed - check $LOGFILE for details."
        fi
	;;
  restart)
	echo -n "Restarting $DESC: "
	if ! $DAEMON -d 2>&1 >>$LOGFILE ; then
                echo "Failed - check $LOGFILE for details."
        fi
	sleep 1
	if $DAEMON 2>&1 >>$LOGFILE ; then
                echo "$NAME."
        else
                echo "Failed - check $LOGFILE for details."
        fi
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	exit 1
	;;
esac

exit 0
