#!/bin/sh
# @(#)postinstall	1.24 12 Jul 1993 Copyright 1993 SMI
#
# Copyright (c) 1993 Sun Microsystems, Inc.  All Rights Reserved.
# Sun considers its source code as an unpublished, proprietary trade
# secret, and it is available only under strict license provisions.
# This copyright notice is placed here only to protect Sun in the event
# the source is deemed a published work.
#
# RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the
# Government is subject to restrictions as set forth in subparagraph
# (c)(1)(ii) of the Rights in Technical Data and Computer Software
# clause at DFARS 52.227-7013 and in similar clauses in the FAR and
# NASA FAR Supplement.
#


echo
echo "postinstall script beginning . . ."

#
#	Correct the symbolic link to HLILIB.a for BugID 1172365
#
installf $PKGINST $BASEDIR/SUNWconn/lib/HLILIB.a=$BASEDIR/SUNWconn/clnt3270/HLILIB.a s
installf -f $PKGINST


#  This part of the script has a simple goal.  We want it to 
#  modify a line in the SunLink 3270 entry of the XTerm file.  
#  Specifically, we want to change:
#
#	Mod3 <Key>F21:  string("0") \n\
#
#  to:
#
#	Mod3 <Key>KP_0:  string("0") \n\
#
#  This change is needed so that user can use the zero key on
#  the numeric keypad.
#
#  This script will back up the current XTerm file as XTerm.prev.
#
#  We are using nawk to search for and modify the appropriate 
#  line.  Note that this line must be within 30 lines of the line:
#
#	SunLink_3270*VT100.Translations:        #override       \n\
#
#  This will help to prevent us from mistakenly modifying
#  a line in another entry in the XTerm file.
#

if (test -s /usr/openwin/lib/app-defaults/XTerm); then

  echo "Saving /usr/openwin/lib/app-defaults/XTerm as XTerm.prev . . ."
  mv /usr/openwin/lib/app-defaults/XTerm /usr/openwin/lib/app-defaults/XTerm.prev


  if (test -s /usr/openwin/lib/app-defaults/XTerm.prev); then

    echo "Updating /usr/openwin/lib/app-defaults/XTerm . . ."

    nawk ' 
{ print }
/SunLink_3270\*VT100\.Translations:/ {
	for (i = 0; i < 30; i++) {
		if (getline > 0) {
			sub(/Mod3 <Key>F21:	string\("0"\)/,"Mod3 <Key>KP_0: string(\"0\")")
			print
		} else {
			exit
		}
	}
}' \
/usr/openwin/lib/app-defaults/XTerm.prev > /usr/openwin/lib/app-defaults/XTerm

    echo "postinstall script has completed successfully . . ."

  else

    echo "Could not modify /usr/openwin/lib/app-defaults/XTerm . . ."
    echo "postinstall script was not successful . . ."
    echo "Please update /usr/openwin/lib/app-defaults/XTerm manually . . ."
    echo "See patch README for details . . ."

  fi

else

  echo "Could not find /usr/openwin/lib/app-defaults/XTerm . . ."
  echo "postinstall script was not successful . . ."
  echo "Please update /usr/openwin/lib/app-defaults/XTerm manually . . ."
  echo "See patch README for details . . ."

fi

echo "End of postinstall script."
echo

