#!/bin/sh

prefix=__PREFIX
exec_prefix=${prefix}
statedir=${prefix}/var/squid
cachedir=${statedir}/cache

squid_user=__UID

PATH=${exec_prefix}/sbin:/bin:/usr/bin
export PATH

cd ${statedir}

case "$1" in
start)
	[ -d "${cachedir}/00" ] \
		|| su -fm $squid_user -c "exec $exec_prefix/sbin/squid -s -z"
	su -fm $squid_user -c "exec $exec_prefix/sbin/squid -s"
	;;
stop)
	su -fm $squid_user -c "exec $exec_prefix/sbin/squid -k shutdown"
	;;
restart)
	$0 stop
	$0 start
	;;
*)
	echo "Usage: `basename $0` {start|stop|restart}" >&2
	;;
esac

exit 0

