#! /bin/sh

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/frox
NAME=frox
DESC="frox: caching ftp proxy server"

# This value is overriden in /etc/default/frox if it exists
RUN_DAEMON=no

test -f $DAEMON || exit 0

# Get configuration
if [ -r /etc/default/frox ]; then
        . /etc/default/frox
fi

case "$1" in
  start)
	echo -n "Starting $DESC: "
	if [ "$RUN_DAEMON" = "yes" ]; then
		start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
		--exec $DAEMON
		echo done
	else
		echo disabled 
	fi
	;;
  stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
		--exec $DAEMON
	echo done 
	;;
  restart|force-reload)
	echo -n "Restarting $DESC: "
	start-stop-daemon --stop --quiet --pidfile \
		/var/run/$NAME.pid --exec $DAEMON
	sleep 1
	start-stop-daemon --start --quiet --pidfile \
		/var/run/$NAME.pid --exec $DAEMON
	echo "$NAME."
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0
