html_cmp revision 1.6 1 #! /bin/sh
2 #
3 # $eterna: html_cmp,v 1.9 2011/11/17 22:18:02 mrg Exp $
4 #
5 # like cmp(1)/diff(1) but compares to files after making their
6 # `Date: ' headers the same, to allow `now' and `then' to work properly.
7 # it also tries to find servername's that might be the local host and
8 # converts those as well..
9 #
10 # it must be called like `html_cmp cmp|diff file1 file1' *only*.
11
12 if [ "cmp" = "$1" ]; then
13 cmd="cmp -s"
14 elif [ "diff" = "$1" ]; then
15 cmd="diff -u"
16 else
17 exit 77
18 fi
19
20 h=`hostname || uname -n`
21
22 sedcmd="s/^Date: .*/Date: nowish/;
23 s/^Last-Modified: .*/Last-Modified: nowish/;
24 s/[a-zA-Z0-9-]*\.eterna\.com\.au/$h/g;
25 s/[a-zA-Z0-9-]*\.eterna23\.net/$h/g;
26 s/^Server: .*/^Server: bozotic HTTP server version 5.08/;
27 s/^Content-Length: .*/Content-Length: 223/;"
28
29 sed -e "$sedcmd" < "$2" > "f1.tmp.$$"
30 sed -e "$sedcmd" < "$3" > "f2.tmp.$$"
31
32 ${cmd} "f1.tmp.$$" "f2.tmp.$$"
33 rv=$?
34 rm -f "f1.tmp.$$" "f2.tmp.$$"
35
36 exit $rv
37