annotate lisp/w3/clean-cache @ 24:4103f0995bd7 r19-15b95

Import from CVS: tag r19-15b95
author cvs
date Mon, 13 Aug 2007 08:51:03 +0200
parents ac2d302a0011
children 131b0175ea99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
1 #!/bin/sh
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
2 #
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
3 # Copyright © 1995, William M. Perry <wmperry@spry.com>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
4 #
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
5 # Author: William M. Perry <wmperry@spry.com>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
6 # Maintainer: William M. Perry <wmperry@spry.com>
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
7 # Created: 95/04/18 10:44:15
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
8 # Version: $Revision: 1.1.1.1 $
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
9 # Modified: $Date: 1996/12/18 03:46:20 $
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
10 # Keywords: cache clean
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
11 #
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
12 # This shell script will clean out your cache directory for emacs-w3
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
13 # It is designed to be run from a cron (see crontab(5)) or at(1)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
14 #
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
15 # This should probably only be run occasionally: like once a month, or
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
16 # when you determine that the cache size is too big. Something like:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
17 #
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
18 # CACHEMAXSIZE=5000
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
19 # SIZE=`du -s $CACHE_ROOT | awk '{print $1}'
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
20 # if [ $SIZE -gt 5000 ] ; then
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
21 # /run/the/real/clean-cache
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
22 # fi
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
23
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
24 if [ -z "$CACHE_ROOT" ] ; then
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
25 CACHE_ROOT=/tmp/$USER # The root directory of the cache
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
26 fi
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
27
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
28 if [ -z "$CONTROL_FILE" ] ; then
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
29 CONTROL_FILE="$CACHE_ROOT/.clean"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
30 fi
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
31
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
32 if [ -z "$CLEAN_PROTOCOLS" ] ; then
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
33 CLEAN_PROTOCOLS="http gopher file ftp wais news"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
34 fi
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
35
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
36 if [ -f "$CONTROL_FILE" ] ; then
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
37 echo "Starting to clean $CACHE_ROOT..." `date`
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
38
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
39 for x in $CLEAN_PROTOCOLS
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
40 do
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
41 if [ -d "$x" ] ; then
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
42 echo " Cleaning $x files"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
43 find $CACHE_ROOT/$x -depth -type f \( ! -anewer "$CONTROL_FILE" \) \
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
44 -exec rm -f {} \;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
45 find $CACHE_ROOT/$x -depth -type d -exec rmdir {} \;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
46 fi
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
47 done
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
48
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
49 touch "$CONTROL_FILE"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
50 echo "Cache clean ended: "`date`
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
51 else
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
52 echo "The cleaning control file ($CONTROL_FILE) could not be found."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
53 echo "To create it (and make all your cache files 'current' do:"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
54 echo ""
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
55 echo "touch $CONTROL_FILE"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
56 echo "find $CACHE_ROOT -exec touch {} \;"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
57 echo ""
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
58 echo "PLEASE NOTE: This can damage your cache, by changing the times it"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
59 echo "sends to the remote server to see if the file was modified."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
60 echo "I recommend just touching the file, then rerunning this script to"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
61 echo "wipe the cache clean and start over."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents:
diff changeset
62 fi