#!/bin/sh
#
#    @(#)postinstall	1.8  94/09/05
#
# Copyright 1993 Sun Microsystems, Inc. All Rights Reserved
#
#  Postinstall script for: SUNWvtexe
#
#	Takes care of Licensing stuff.


# Exit codes for installation scripts 
e_ok=0      
e_fatal=1      # stop installation on this exit
e_warning=2    # Installation will go on. 
e_int=3        # Interrupted. Stop installation
e_reboot=10    # User must reboot after installation of all selected packages
e_rebootnow=20 # User must reboot right after installation of current package
               # To be added to one of the single-digit exit code above

# Trap interrupt
trap `exit $e_int` 15

# @(#)postinstall_prod	1.6 11/19/92 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.
#
# Post-install template for unbundled products using FLEXlm
# Copies all licenses over from the standard directory - $licdir -

###########################################
# The following lines should be modified for use by individual products
###########################################
# Identifies the basename of the license file and license
# location file, before the ,loc or,lic are attached to it
# e.g., if license_file=featfile
# the license file will then be called featfile,lic

license_file=osivt8.0

# Identifies the path to the license once it is installed
# in the product, excluding the basedir and the license file name
# e.g., if dirloc=SUNWspro/lib, the license file would be placed in
# $BASEDIR/SUNWspro/lib

dirloc=SUNWconn/license_dir

####################################################
# Subsequent lines should not be modified by individual products
#####################################################
licdir="/etc/opt/licenses"
licfile=${license_file}.lic
locfile=${license_file}.loc

if [ ! -d ${BASEDIR}/${dirloc} ]
then
	echo Cannot Access license location directory ${BASEDIR}/${dirloc}  - Exiting
	exit 1
fi

#
# Find new names for existing new license files in licdir
#
if [ -f  ${licdir}/${licfile}* ]
then 
	for infile in `ls ${licdir}/${licfile}*`
	do

		i=0
		notdone=0
		while [ $notdone -eq 0 ]
		do
			outputfile=$BASEDIR/$dirloc/$licfile,$i
			if [ ! -f $outputfile ]
			then
				notdone=1
			else
				i=`expr $i + 1`
			fi
		done
		
# Get the basename, just in case we don't know the formate of this name
		basefile=`basename ${infile}`
		cp ${licdir}/${basefile} $outputfile
		if [ $? -ne 0 ]
		then
			echo Exiting
			exit 1
		fi
		rm ${licdir}/${basefile}
	done
	echo Licenses copied to $BASEDIR/$dirloc
else
	echo No licenses available to insert.
	echo Make sure to run the license insertion tool or the license \
configuration script on this machine.
fi

echo $BASEDIR/${dirloc} > ${licdir}/${locfile}
if [ $? -ne 0 ]
then
	echo Cannot Access license location file ${licdir}/${locfile}  - Exiting
	exit 1
fi


# End
exit $e_value

