1 |
dpavlin |
10 |
#! /bin/sh |
2 |
|
|
|
3 |
|
|
#================================================================ |
4 |
|
|
# estwolels |
5 |
|
|
# List the path of cache files of wwwoffle |
6 |
|
|
#================================================================ |
7 |
|
|
|
8 |
|
|
|
9 |
|
|
# set variables |
10 |
|
|
LANG=C ; export LANG |
11 |
|
|
LC_ALL=C ; export LC_ALL |
12 |
|
|
progname="estwolels" |
13 |
|
|
spooldir=/var/spool/wwwoffle |
14 |
|
|
denysufs="css|js|dtd|rdf|rss|swf|class|md5" |
15 |
|
|
denysufs="$denysufs|png|gif|jpg|jpeg|jpe|bmp|tif|tiff" |
16 |
|
|
denysufs="$denysufs|pnm|pbm|pgm|ppm|xbm|xpm|ps|eps|au|svg|dvi|ico" |
17 |
|
|
denysufs="$denysufs|mid|midi|kar|mp3|mp2|au|snd|wav|aif|aiff" |
18 |
|
|
denysufs="$denysufs|mpg|mpeg|mpe|qt|mov|avi" |
19 |
|
|
denysufs="$denysufs|pdf|rtf|rtx|doc|xls|ppt|xdw|csv|tsv" |
20 |
|
|
denysufs="$denysufs|gz|zip|bz2|lzh|lha|tar|bin|cpio|shar|jar|war" |
21 |
|
|
sizemax="1048576" |
22 |
|
|
|
23 |
|
|
# show help message |
24 |
|
|
if [ "$1" = "--help" ] |
25 |
|
|
then |
26 |
|
|
printf 'List the path and the URL of cache files of wwwoffle.\n' |
27 |
|
|
printf '\n' |
28 |
|
|
printf 'Usage:\n' |
29 |
|
|
printf ' %s [spooldir]\n' "$progname" |
30 |
|
|
printf '\n' |
31 |
|
|
exit 0 |
32 |
|
|
fi |
33 |
|
|
|
34 |
|
|
|
35 |
|
|
# check the spool directory |
36 |
|
|
if [ -n "$1" ] |
37 |
|
|
then |
38 |
|
|
spooldir="$1" |
39 |
|
|
fi |
40 |
|
|
if [ -d "$spooldir/http" ] && [ -r "$spooldir/http" ] && [ -x "$spooldir/http" ] |
41 |
|
|
then |
42 |
|
|
true |
43 |
|
|
else |
44 |
|
|
printf '%s: cannot scan %s\n' "$progname" "$spooldir/http" 1>&2 |
45 |
|
|
exit 1 |
46 |
|
|
fi |
47 |
|
|
|
48 |
|
|
|
49 |
|
|
# list the path and the URL of cache files |
50 |
|
|
ls "$spooldir/http" | |
51 |
|
|
while read domain |
52 |
|
|
do |
53 |
|
|
wwwoffle-ls "http://$domain" |
54 |
|
|
done | |
55 |
|
|
fgrep " http://" | |
56 |
|
|
egrep -i -v "\.($denysufs)$" | |
57 |
|
|
awk -F ' ' -v sdir="$spooldir/http" -v sizemax="$sizemax" ' |
58 |
|
|
{ |
59 |
|
|
if($2 < 1 || $2 > sizemax) next |
60 |
|
|
file = $0 |
61 |
|
|
sub(/ .*/, "", file) |
62 |
|
|
domain = $0 |
63 |
|
|
sub(/.* http:\/\//, "", domain) |
64 |
|
|
sub(/\/.*/, "", domain) |
65 |
|
|
url = $0 |
66 |
|
|
sub(/.* http:\/\//, "", url) |
67 |
|
|
printf("%s/%s/%s\thttp://%s\n", sdir, domain, file, url) |
68 |
|
|
} |
69 |
|
|
' |
70 |
|
|
|
71 |
|
|
|
72 |
|
|
# exit normally |
73 |
|
|
exit 0 |
74 |
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
# END OF FILE |