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
12if [ "cmp" = "$1" ]; then
13	cmd="cmp -s"
14elif [ "diff" = "$1" ]; then
15	cmd="diff -u"
16else
17	exit 77
18fi
19
20h=`hostname || uname -n`
21
22sedcmd="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
29sed -e "$sedcmd" < "$2" > "f1.tmp.$$"
30sed -e "$sedcmd" < "$3" > "f2.tmp.$$"
31
32${cmd} "f1.tmp.$$" "f2.tmp.$$"
33rv=$?
34rm -f "f1.tmp.$$" "f2.tmp.$$"
35
36exit $rv
37