#!/bin/sh
set +e;

#------------------------------------------------------------------------------
# Autoconf variables - in a form suitable for sh, perl
# Generated automatically from autoconf.sh.in by configure.
#------------------------------------------------------------------------------
# Variables for, and by, Autoconf (Don't touch these! edit config step)
PACKAGE_NAME="@PACKAGE_NAME@";
PACKAGE_VERSION="@PACKAGE_VERSION@";
prefix="@prefix@";
exec_prefix="@exec_prefix@";
bindir="@bindir@";
sbindir="@sbindir@";
libexecdir="@libexecdir@";
datadir="@datadir@";
sysconfdir="@sysconfdir@";
sharedstatedir="@sharedstatedir@";
localstatedir="@localstatedir@";
libdir="@libdir@";
includedir="@includedir@";
infodir="@infodir@";
mandir="@mandir@";
docdir="@docdir@";
srcdir="@srcdir@";

copies=2;

# backup "/etc/mail/sendmail.mc"
if [ -f ${sysconfdir}/mail/sendmail.mc ]; then
	if [ ! -f ${localstatedir}/backups/sendmail.mc.bak ]; then
		cp -pf ${sysconfdir}/mail/sendmail.mc \
			${localstatedir}/backups/sendmail.mc.bak;
	   	fi;
	if ! cmp -s ${localstatedir}/backups/sendmail.mc.bak \
		${sysconfdir}/mail/sendmail.mc ; then
		cd ${localstatedir}/backups;
		/usr/bin/savelog -p -c $copies sendmail.mc.bak > /dev/null;
		cp -pf ${sysconfdir}/mail/sendmail.mc \
			${localstatedir}/backups/sendmail.mc.bak;
		fi;
	fi;

# backup "/etc/mail/submit.mc"
if [ -f ${sysconfdir}/mail/submit.mc ]; then
	if [ ! -f ${localstatedir}/backups/submit.mc.bak ]; then
		cp -pf ${sysconfdir}/mail/submit.mc \
			${localstatedir}/backups/submit.mc.bak;
		fi;
	if ! cmp -s ${localstatedir}/backups/submit.mc.bak \
		${sysconfdir}/mail/submit.mc ; then
		cd ${localstatedir}/backups;
		/usr/bin/savelog -p -c $copies submit.mc.bak > /dev/null;
		cp -pf ${sysconfdir}/mail/submit.mc \
			${localstatedir}/backups/submit.mc.bak;
		fi;
	fi;

# while we're here, might as well do sendmail.cf
if [ -f ${sysconfdir}/mail/sendmail.cf ]; then
	if [ ! -f ${localstatedir}/backups/sendmail.cf.bak ]; then
		cp -pf ${sysconfdir}/mail/sendmail.cf \
			${localstatedir}/backups/sendmail.cf.bak;
		fi;
	if ! cmp -s ${localstatedir}/backups/sendmail.cf.bak \
		${sysconfdir}/mail/sendmail.cf ; then
		cd ${localstatedir}/backups;
		# save previous generation only if differences are significant
		diff -bBwI "^\#\#\#\#\# " \
			${localstatedir}/backups/sendmail.cf.bak \
			${sysconfdir}/mail/sendmail.cf > /dev/null;
		if [ $? -ne 0 ]; then
			/usr/bin/savelog -p -c $copies sendmail.cf.bak \
				> /dev/null;
			fi;
		cp -pf ${sysconfdir}/mail/sendmail.cf \
			${localstatedir}/backups/sendmail.cf.bak;
		fi;
	fi;

# while we're here, might as well do submit.cf
if [ -f ${sysconfdir}/mail/submit.cf ]; then
	if [ ! -f ${localstatedir}/backups/submit.cf.bak ]; then
		cp -pf ${sysconfdir}/mail/submit.cf \
			${localstatedir}/backups/submit.cf.bak;
		fi;
	if ! cmp -s ${localstatedir}/backups/submit.cf.bak \
		${sysconfdir}/mail/submit.cf ; then
		cd ${localstatedir}/backups;
		# save previous generation only if differences are significant
		diff -bBwI "^\#\#\#\#\# " \
			${localstatedir}/backups/submit.cf.bak \
			${sysconfdir}/mail/submit.cf > /dev/null;
		if [ $? -ne 0 ]; then
			/usr/bin/savelog -p -c $copies submit.cf.bak \
				> /dev/null;
			fi;
		cp -pf ${sysconfdir}/mail/submit.cf \
			${localstatedir}/backups/submit.cf.bak;
		fi;
	fi;
