#!/bin/sh
#
# Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
#ident "@(#)postpatch        1.9     02/04/16 SMI"
#

# Only run this script if this is a Netra ct machine.

if [ `uname -i` != "SUNW,UltraSPARC-IIi-Netract" ] &&
 [ `uname -i` != "SUNW,UltraSPARC-IIe-NetraCT-40" ] ;
then
	exit 0
fi

# Echo the special Install Instructions
echo "*********** SPECIAL INSTALLATION INSTRUCTIONS ***********"
echo "To complete the installation of this patch,"
echo "run the 'rscadm' command to download the new"
echo "firmware image to the flash of the Alarm Card."
echo "example# cd /usr/platform/SUNW,UltraSPARC-IIi-Netract/rsc"
echo "example# ./rscadm download ../lib/images/rscfw"
echo ""
echo "After the download has completed, the Alarm Card will"
echo "reboot itself.  The Alarm Card reboot & self-tests take"
echo "approximately 40 seconds, afterwhich time, the Alarm Card"
echo "will be available for use."
echo "*********** SPECIAL INSTALLATION INSTRUCTIONS ***********"
echo " "
echo "To get alarm card firmware version run the following command."
echo "example# pkgparam SUNWctac ALARM_CARD_FW_VERSION"

# Bug #4335007  postinstall script


# 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

# Modify /etc/iu.ap, by adding entry for the Netra ct se device
# that communicates with the Alarm Card

if [ ! -f $RDIR/etc/iu.ap ]; then
        exit 0
fi

if fgrep -s "	se	16384	0	ldterm ttcompat" $RDIR/etc/iu.ap ; then
    echo "/etc/iu.ap not modified."
    exit 0
fi

# Upgrade path, remove the bad entry
if fgrep -s "	se	16384	16385	ldterm ttcompat" $RDIR/etc/iu.ap ; then
	sed -e "s/	se	16384	16385	ldterm ttcompat/	se	16384	0	ldterm ttcompat/"  $RDIR/etc/iu.ap > /tmp/iu.ap
	if [ $? != 0 ] ; then
		echo "/etc/iu.ap file modification failed"
		exit 1
	else
		mv /tmp/iu.ap $RDIR/etc/iu.ap
		echo "/etc/iu.ap file successfully modified"
		exit 0
	fi
fi


# Apply the patch
cp $RDIR/etc/iu.ap /tmp/iu.ap
echo 		 "	se	16384	0	ldterm ttcompat" >> $RDIR/etc/iu.ap
if [ $? != 0 ] ; then
    echo "/etc/iu.ap file modification failed"
    mv /tmp/iu.ap $RDIR/etc/iu.ap
    exit 1
else
    echo "/etc/iu.ap file successfully modified"
    exit 0
fi



