OpenSolaris_b135/pkgdefs/SUNWcsr/preinstall

#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#

#
# When first introduced the /etc/inet/ipnodes file was seperate from
# /etc/inet/hosts.  It is now a symbolic link to /etc/inet/hosts.  The
# i.hosts class action script merges the saved temporary ipnodes file 
# into a single hosts file.
#
if [ ! -h $BASEDIR/etc/inet/ipnodes ]; then
	if [ -f $BASEDIR/etc/inet/ipnodes ]; then
		cp -f $BASEDIR/etc/inet/ipnodes \
			$BASEDIR/etc/inet/ipnodes.hostsmerge
	fi
fi

#
# TIMEZONE.temp is processed and removed by the i.definit class action
# script.
#
if [ -f $BASEDIR/etc/TIMEZONE ] ; then
	cp $BASEDIR/etc/TIMEZONE $BASEDIR/etc/TIMEZONE.temp
fi

# mail.ABCsavedXYZ is processed and removed by postinstall
if [ -h $BASEDIR/var/mail ] ; then
	rm -rf $BASEDIR/var/mail.ABCsavedXYZ
	mv $BASEDIR/var/mail $BASEDIR/var/mail.ABCsavedXYZ
fi

# news.ABCsavedXYZ is processed and removed by postinstall
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

# We apply the limited profile on initial installs of the OS and on
# initial installs of zones. We don't apply it on upgrades or patches.

if [ "x$PKG_INIT_INSTALL" = "xTRUE" ]; then
	touch $BASEDIR/var/SUNWcsr-apply-limited-net
elif [ -n "$SUNW_PKG_INSTALL_ZONENAME" -a \
    "$SUNW_PKG_INSTALL_ZONENAME" != "global" ]; then
	touch $BASEDIR/var/SUNWcsr-apply-limited-net
fi

if [ "$UPDATE" = yes ]; then
	# Check for existing smf(5) manifests
	BASEPREFIX=`echo $BASEDIR | sed "s/\//_/g"`
	if [ -f ${PKG_INSTALL_ROOT}/var/svc/network/ipsec/ike.xml ]; then
		IKEMANIFEST=`echo ike.xml"$BASEPREFIX" | cut -c 1-256`
		touch /tmp/${IKEMANIFEST}
	fi
	if [ -f ${PKG_INSTALL_ROOT}/var/svc/network/ipsec/manual-key.xml ]; then
		MANKEYMANIFEST=`echo manual-key.xml$BASEPREFIX" | cut -c 1-256`
		touch /tmp/${MANKEYMANIFEST}
	fi
fi

exit 0