html_cmp revision 1.6
11.1Stls#! /bin/sh
21.1Stls#
31.4Smrg#	$eterna: html_cmp,v 1.9 2011/11/17 22:18:02 mrg Exp $
41.1Stls#
51.5Sschmonz# like cmp(1)/diff(1) but compares to files after making their
61.5Sschmonz# `Date: ' headers the same, to allow `now' and `then' to work properly.
71.5Sschmonz# it also tries to find servername's that might be the local host and
81.5Sschmonz# converts those as well..
91.1Stls#
101.5Sschmonz# it must be called like `html_cmp cmp|diff file1 file1' *only*.
111.5Sschmonz
121.5Sschmonzif [ "cmp" = "$1" ]; then
131.5Sschmonz	cmd="cmp -s"
141.5Sschmonzelif [ "diff" = "$1" ]; then
151.5Sschmonz	cmd="diff -u"
161.5Sschmonzelse
171.5Sschmonz	exit 77
181.5Sschmonzfi
191.1Stls
201.1Stlsh=`hostname || uname -n`
211.1Stls
221.1Stlssedcmd="s/^Date: .*/Date: nowish/;
231.1Stls	s/^Last-Modified: .*/Last-Modified: nowish/;
241.1Stls	s/[a-zA-Z0-9-]*\.eterna\.com\.au/$h/g;
251.6Smrg	s/[a-zA-Z0-9-]*\.eterna23\.net/$h/g;
261.1Stls	s/^Server: .*/^Server: bozotic HTTP server version 5.08/;
271.1Stls	s/^Content-Length: .*/Content-Length: 223/;"
281.1Stls
291.5Sschmonzsed -e "$sedcmd" < "$2" > "f1.tmp.$$"
301.5Sschmonzsed -e "$sedcmd" < "$3" > "f2.tmp.$$"
311.1Stls
321.5Sschmonz${cmd} "f1.tmp.$$" "f2.tmp.$$"
331.1Stlsrv=$?
341.4Smrgrm -f "f1.tmp.$$" "f2.tmp.$$"
351.1Stls
361.1Stlsexit $rv
37