#!/bin/sh

# fixup - do standard substitutions on the specified file
# $Id: fixup,v 1.19 2003/05/15 12:03:54 remstats Exp $
# from remstats @@VERSION@@

# Copyright 1999-2003 (c) Thomas Erskine <@@AUTHOR@@>
# See the COPYRIGHT file with the distribution.

# - - -   Version History   - - -

# $Revision: 1.19 $

# - - -   Setup   - - -

if [ $# != 1 ] ; then
	echo >&2 "usage: $0 file"
	exit 1
fi

if [ ! -f fixup.config ] ; then
	echo >&2 "$0: missing fixup.config file"
	exit 2
fi

if [ -f VERSION ] ; then
	VERSION=`cat VERSION`
else
	echo >&2 "$0: missing VERSION file"
	exit 3
fi

if [ -f BESTAVAILABLEVERSION ] ; then
	BESTAVAILABLEVERSION=`cat BESTAVAILABLEVERSION`
else
	echo >&2 "$0: missing BESTAVAILABLEVERSION file"
	exit 3
fi

DATE=`date`

. ./fixup.config

sed \
	-e "s#@@PERL@@#$PERL#g" \
	-e "s#@@PERLOPTS@@#$PERLOPTS#g" \
	-e "s#@@PERLCGIOPTS@@#$PERLCGIOPTS#g" \
	-e "s#@@INSTALLDIR@@#$INSTALLDIR#g" \
	-e "s#@@BINDIR@@#$BINDIR#g" \
	-e "s#@@ETCDIR@@#$ETCDIR#g" \
	-e "s#@@LIBDIR@@#$LIBDIR#g" \
	-e "s#@@MANDIR@@#$MANDIR#g" \
	-e "s#@@MANSECT@@#$MANSECT#g" \
	-e "s#@@CONFIGDIR@@#$CONFIGDIR#g" \
	-e "s#@@RRDLIBDIR@@#$RRDLIBDIR#g" \
	-e "s#@@RRDCGI@@#$RRDCGI#g" \
	-e "s#@@DATADIR@@#$DATADIR#g" \
	-e "s#@@DATAPAGEDIR@@#$DATAPAGEDIR#g" \
	-e "s#@@ERRORLOGDIR@@#$ERRORLOGDIR#g" \
	-e "s#@@HTMLDIR@@#$HTMLDIR#g" \
	-e "s#@@HTMLURL@@#$HTMLURL#g" \
	-e "s#@@CGIDIR@@#$CGIDIR#g" \
	-e "s#@@CGIURL@@#$CGIURL#g" \
	-e "s#@@WEBMASTER@@#$WEBMASTER#g" \
	-e "s#@@ALERTEMAIL@@#$ALERTEMAIL#g" \
	-e "s#@@REMSTATSPORT@@#$REMSTATSPORT#g" \
	-e "s#@@VERSION@@#$VERSION#g" \
	-e "s#@@BESTAVAILABLEVERSION@@#$BESTAVAILABLEVERSION#g" \
	-e "s#@@SENDMAIL@@#$SENDMAIL#g" \
	-e "s#@@OURSITEEMAIL@@#$OURSITEEMAIL#g" \
	-e "s#@@DATEPROG@@#$DATEPROG#g" \
	-e "s#@@DATE@@#$DATE#g" \
	-e "s#@@OWNER@@#$OWNER#g" \
	-e "s#@@GROUP@@#$GROUP#g" \
	-e "s#@@WEBGROUP@@#$WEBGROUP#g" \
	-e "s#@@DIRMODE@@#$DIRMODE#g" \
	-e "s'@@DEBUG@@'$DEBUG'" \
	-e "s#@@AUTHOR@@#terskine@users.sourceforge.net#g" \
	-e "s#@@SRCURL@@#http://remstats.sourceforge.net/release/#g" \
	-e "s#@@RRDTOOLHOME@@#http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/#g" \
	-e "s#@@RRDTOOLLOGO@@#rrdtool.gif#g" \
	-e 's#@@DOCTYPE@@#<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">#g' \
	-e "s#@@MAILINGLIST@@#remstats-list@lists.sourceforge.net#g" \
$1
