postinstall revision 7c478bd95313f5f23a4c958a745db2134aa03244
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (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 2004 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
#
PATH=/usr/bin:/usr/sbin
CLEANUP=/tmp/CLEANUP
system=/tmp/usr.lib.mail.system.$$
actual=/tmp/usr.lib.mail.actual.$$
added_abs=/tmp/usr.lib.mail.user-added.abs.$$
added_rel=/tmp/usr.lib.mail.user-added.rel.$$
UPGRADE=$BASEDIR/var/svc/profile/upgrade
rm -f $BASEDIR/etc/mail/aliases.db
rm -f $BASEDIR/etc/mail/aliases.dir
rm -f $BASEDIR/etc/mail/aliases.pag
# During SunOS 5.10, sendmail's m4 configuration hierarchy moved from
# /usr/lib/mail/ to /etc/mail/cf/ . Ordinary packaging will deal with
# the bulk of the move, but since users are not only allowed but encouraged
# to create files within this hierarchy, we need to migrate any such files
# from the old to the new location.
# During an upgrade, the old SUNWsndmu will be pkgrm'd before the new
# SUNWsndmr (or u) is pkgadd'd. The pkgrm should have cleaned out all
# the system files under /usr/lib/mail, so we need to consider that case,
# as well as the user running pkgadd at other times.
[ -d $BASEDIR/usr/lib/mail ] || exit 0
# Get /usr/lib/mail package contents of type f, formerly under SUNWsndmu.
pkgchk -L SUNWsndmu | nawk '{if ($2 == "f") {print $1}}' | \
grep '^/usr/lib/mail/' | sort > $system
find $BASEDIR/usr/lib/mail -type f | sed -e "s|^$BASEDIR/|/|" | sort > $actual
# Actual should be a superset of system, so ignore anything in both
comm -3 $system $actual | sed -e 's/ //' > $added_abs
rm -f $system $actual
if [ ! -s $added_abs ]; then
rm -f $added_abs
exit 0
fi
# Strip out the leading path to make relativity easier for tar
sed -e 's|/usr/lib/mail/||' $added_abs > $added_rel
rm -f $added_abs
# In theory, this should not happen, but be defensive
if [ ! -s $added_rel ]; then
rm -f $added_rel
exit 0
fi
# Now move all the files to the new location
cd $BASEDIR/usr/lib/mail
tar cf - -I $added_rel . | ( cd $BASEDIR/etc/mail/cf ; tar xpf - )
# Blow away the files from the old location
rm -f `cat $added_rel`
echo "The following files have been moved from /usr/lib/mail to /etc/mail/cf" \
>> $CLEANUP
cat $added_rel >> $CLEANUP
rm -f $added_rel
# We just cleaned out any user added files, which in the upgrade scenario
# should just leave some skeleton directories: blow them away now. To
# cover the non-upgrade scenario, however, we don't use "rm -f", but just
# opportunistically rmdir the skeleton directories, ignoring any errors.
cd /
find $BASEDIR/usr/lib/mail -depth -type d 2>/dev/null | \
xargs rmdir > /dev/null 2>&1
exit 0