#
# Copyright (c) 1993, 1998, 1999 by Sun Microsystems, Inc.
# All rights reserved.
#
#ident	"@(#)preinstall	1.8	99/06/18 SMI"

if [ -f $BASEDIR/etc/TIMEZONE ] ; then
	cp $BASEDIR/etc/TIMEZONE $BASEDIR/etc/TIMEZONE.temp
fi
if [ -f $BASEDIR/etc/inetd.conf ] ; then
	cp $BASEDIR/etc/inetd.conf $BASEDIR/etc/inetd.conf.temp
fi

if [ -h $BASEDIR/var/mail ] ; then
	rm -rf $BASEDIR/var/mail.ABCsavedXYZ
	mv $BASEDIR/var/mail $BASEDIR/var/mail.ABCsavedXYZ
fi

if [ -h $BASEDIR/var/news ] ; then
	rm -rf $BASEDIR/var/news.ABCsavedXYZ
	mv $BASEDIR/var/news $BASEDIR/var/news.ABCsavedXYZ
fi

CLEANUP=/tmp/CLEANUP

print_dhcptags_warning() {

	cat >> $CLEANUP <<-EOF
	You have made changes to /etc/dhcp/dhcptags, which has been superseded
	by /etc/dhcp/inittab, as documented in dhcp_inittab(4).  Please refer
	to the DHCP documentation in the Answerbook for information on how to
	convert your existing customizations.
	EOF
}

if [ "x$UPDATE" = xyes ]; then

	DHCPTAGS=$BASEDIR/etc/dhcp/dhcptags

	# If the dhcptags file has been modified, then install moved
	# it to a funky name like /etc/dhcp/dhcptags:8.  Use this as
	# an opportunity to issue a warning to the user.  Since the
	# file may be left over from a previous upgrade, only issue
	# the warning if the current package database is familiar with
	# the file.
	#
	# The construct ${PKG_INSTALL_ROOT:-/} is used instead of
	# $PKG_INSTALL_ROOT/ because the packaging subsystem will
	# think we're changing the path (from $PKG_INSTALL_ROOT to
	# $PKG_INSTALL_ROOT/) and will output spurious warnings.
	#
	# We need to pass in the -R since otherwise we will get a
	# warning from a `make install' on this package that we may
	# be accessing a stale package database (in fact, this won't
	# happen since installf and friends inherit the
	# $PKG_INSTALL_ROOT environment variable).  Note that the -R
	# must be on the same line as the command it's used with.
	#
	# ${CLIENT_BASEDIR}foo is used instead of $CLIENT_BASEDIR/foo
	# because the packaging commands don't always realize that
	# //foo and /foo are the same file.

	if [ "`echo $DHCPTAGS:*`" != "$DHCPTAGS:*" ]; then
		pkgchk -l -R ${PKG_INSTALL_ROOT:-/}			\
		    -p ${CLIENT_BASEDIR}etc/dhcp/dhcptags $PKGINST |    \
		    grep -i installed > /dev/null 2>&1 &&		\
		    print_dhcptags_warning
	fi	
fi

exit 0
