#!/bin/sh
#
#ident	"@(#)i.sendmail	1.2	00/04/21 SMI"
#
# Copyright (c) 2000 by Sun Microsystems, Inc.
#
#
CLEANUP_FILE=/tmp/CLEANUP

#
# Sendmail 8.9 used the file names sendmail.cw and sendmail.ct, whereas 8.10
# uses local-host-names and trusted-users respectively (all in /etc/mail).
# So first check if the file exists by the new name; if so, do nothing.
# Then check the old name; if that exists, hard-link the old name and the
# new name.  If neither name exists, just install the default version.
#

handle() {
	if [ `basename $2` = $4 ] ; then
		OLDFILE="`dirname $2`/$3"
		if [ -f $2 ]; then
			return
		elif [ -f $OLDFILE ]; then
			ln $OLDFILE $2
			echo "EXISTING_FILE_RENAMED: $OLDFILE $2" \
				>> $CLEANUP_FILE
		else
			cp -p $1 $2
		fi
	fi
}

while read src dest
do
	if [ ! -f $dest ] ; then
		handle $src $dest "sendmail.cw" "local-host-names"
		handle $src $dest "sendmail.ct" "trusted-users"
	fi
done
exit 0
