#! /bin/sh
#
# squid		Startup script for the SQUID caching HTTP server.
#		This one is a bit different then usual because
#		a it has a shell script wrapper around it to watch
#		over it.
#
# Version:	@(#)squid.rc  1.03  14-Aug-1996  MvS.
#

PATH=/bin:/usr/bin:/sbin:/usr/sbin
DIR=/usr/sbin
LIB=/usr/lib/squid
PIDFILE=/var/run/squid.pid

case "$1" in
  start)
    # If a server is running, do not restart.
    pid="`pidof -o %PPID -o $$ $DIR/squid`"
    if [ "$pid" = "" ]
    then
	echo "starting squid through RunCache..."
	cd /var/spool/squid
	logdir=/var/log/squid
	export logdir
	$LIB/RunCache /etc/squid.conf < /dev/null > /dev/console 2>&1 &
	sleep 2
    fi
    ;;
  stop)
    # First kill the watch process, then the daemon.
    killall -9 RunCache 2>/dev/null
    start-stop-daemon --stop --verbose --pidfile $PIDFILE --exec $DIR/squid
    ;;
  reload)
    echo "Reloading squid configuration files"
    start-stop-daemon --stop --signal 1 --pidfile $PIDFILE --quiet --exec $DIR/squid
    ;;
  *)
    echo "Usage: /etc/init.d/squid {start|stop|reload}"
    exit 1
    ;;
esac

exit 0
