#!/bin/sh
#
# Copyright (c) 2000, by Sun Microsystems, Inc.
# All rights reserved.
#
# Postpatch modified on 02/06/2001 to fix jumpstart bug, #4365273, #4369863
#

# Determine if installation is via jumpstart

echo $BASEDIR | grep '^\/a' > /dev/null
if [ $? = 0 ]
    then
        JUMPSTART=1
    else
        JUMPSTART=0
fi

# Set base directory as appropriate for installation

if [ "$BASEDIR" = '/' ]
then
        PDIR=''
else
        PDIR="$BASEDIR"
fi

# Set path and make exportable

PATH="/bin:/usr/bin:/usr/sbin:$PDIR/bin:$PDIR/usr/bin:$PDIR/usr/sbin"
export PATH

if [ "$JUMPSTART" = 1 ]
then
        RDIR="$BASEDIR"
else
        RDIR="$ROOTDIR"
fi

# add the SUNW2jdrt and SUNWctmgx packages after the patch is installed.

PKGADD=/usr/sbin/pkgadd
RM="/usr/bin/rm -f"
RMDIR=/usr/bin/rmdir

TMP_DIR=$RDIR/opt/SUNWnetract/tmp

# packagesource is a file generated by pkgtrans for SUNW2jdrt and SUNWctmgx
# adminfile is a file for non-interactive pkgadd

${PKGADD} -R $RDIR -d $TMP_DIR/packagesource -a $TMP_DIR/adminfile SUNW2jdrt SUNWctmgx

# save exit status of pkgadd
pkgadd_OK=$?

# remove the temporary files
${RM} $TMP_DIR/packagesource $TMP_DIR/adminfile
${RMDIR} $TMP_DIR

if [ $pkgadd_OK != 0 ] ; then
   echo " SUNW2jdrt and SUNWctmgx installation failed "
   exit 1
else
   exit 0
fi
