#!/bin/sh
# This script monitors free disk space, and clears the Squid cache, should
# the used disk space rise above a threshold.
# THRESHOLD is given as a percentage of used disk space, in this case.
#
# Copyright (c) 2003 by Paul Kreiner

THRESHOLD=97
SQUIDDIR=/var/spool/squid
MAILTO=root

if [ `df | grep md0 | cut --bytes=52-54` -le $THRESHOLD ]; then
  exit 0
else
  killall -q RunCache; killall -q squid
  sleep 3
  killall -q -9 RunCache; killall -q -9 squid

  rm -rf $SQUIDDIR/0*
  sync

  squid -z
  squid
  squid
fi

