#!/bin/bash
#
# Startup script for ndtpd
#
# chkconfig: - 85 15
# description: ndtpd is server for accessing CD-ROM books with NDTP.
# processname: ndtpd
# config: /etc/ndtpd.conf

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

# Source additional OPTIONS if we have them.
if [ -f /etc/sysconfig/ndtpd ] ; then
	. /etc/sysconfig/ndtpd
fi

# Path to the httpd binary.
ndtpd=/usr/sbin/ndtpd
prog=ndtpd
RETVAL=0

# Change the major functions into functions.
start() {
	echo -n "Starting $prog: "
	daemon $ndtpd $OPTIONS
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && touch /var/lock/subsys/ndtpd
	return $RETVAL
}
stop() {
	echo -n "Stopping $prog: "
	killproc $ndtpd
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && rm -f /var/lock/subsys/ndtpd \
	    /var/lib/ndtpd/ndtpd.pid /var/lib/ndtpd/*.lock
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
	status $ndtpd
	;;
  restart)
	stop
	start
	;;
  reload)
	echo -n "Reloading $prog: "
	killproc $ndtpd -HUP
	RETVAL=$?
	echo
	;;
  condrestart)
	if [ -f /var/lib/ndtpd/ndtpd.pid ] ; then
		stop
		start
	fi
	;;
  *)
	echo "Usage: $prog {start|stop|restart|reload|condrestart|status}"
	exit 1
esac

exit $RETVAL
