#! /bin/sh
### BEGIN INIT INFO
# Provides:          squid-prefetch
# Required-Start:    $remote_fs $syslog squid
# Required-Stop:     $remote_fs $syslog squid
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
### END INIT INFO

DAEMON=/usr/sbin/squid-prefetch
NAME=squid-prefetch
DESC="prefetch daemon for squid"

test -f $DAEMON || exit 0

set -e

case "$1" in
  start)
	echo -n "Starting $DESC: "
	start-stop-daemon --start --background --quiet --make-pidfile --pidfile /var/run/$NAME.pid \
		--exec $DAEMON >/dev/null 2>&1
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid >/dev/null 2>&1
	rm -f /var/run/$NAME.pid
	echo "$NAME."
	;;
  restart|force-reload)
	#
	#	If the "reload" option is implemented, move the "force-reload"
	#	option to the "reload" entry above. If not, "force-reload" is
	#	just the same as "restart".
	#
	$0 stop
	$0 start
	;;
  *)
	N=/etc/init.d/$NAME
	# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	echo "Usage: $N {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0
