OpenSolaris_b135/pkgdefs/SUNWppmr/postinstall

#
# 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 2009 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
#

#
# If appropriate, enable this service.
#
BASEPREFIX=`echo $BASEDIR | sed "s/\//_/g"`

PPDFILENAME=`echo sunwppmr_ppd_cache_update"$BASEPREFIX" | cut -c 1-256`
PPDTMPFILE=/tmp/$PPDFILENAME
if [ -f $PPDTMPFILE ] ; then

	# Enable the ppd-cache-update service.
	echo "/usr/sbin/svcadm enable application/print/ppd-cache-update" >> \
	    $BASEDIR/var/svc/profile/upgrade

	# Ensure pre-existing printer configuration files with an
	# old system PPD file delivery location are updated to
	# reflect the newest location of PPD files.
	NEW_PATH=/usr/share/ppd
	if [ -d $NEW_PATH ] ; then
		OLD_PATH=/usr/lib/lp/model/ppd/system
		PNTRS=$BASEDIR/etc/lp/printers
		for f in `/bin/find $PNTRS -name configuration 2>/dev/null` ; do
		    /bin/grep ${OLD_PATH} ${f} >/dev/null 2>&1
			if [ $? -eq 0 ] ; then
				/bin/sed \
		    -e "s;${OLD_PATH}/foomatic;${NEW_PATH}/SUNWfoomatic;g" \
		    -e "s;${OLD_PATH}/gimp;${NEW_PATH}/SUNWgimp;g" \
                    -e "s;${OLD_PATH}/hpijs;${NEW_PATH}/SUNWhpijs;g" \
		    ${f} >/tmp/lp.$$
				/bin/mv -f /tmp/lp.$$ ${f}
			fi
		done
		rm $PPDTMPFILE
	fi
fi

exit 0